• DriveMan_邱佳源
    2018-12-30
    个人笔记总结
    git remote -v 查看远程版本库信息
    git remote add githup <url> 添加githup远程版本库
    git fetch githup 拉取远程版本库
    git merge -h 查看合并帮助信息
    git merge --allow-unrelated-histories githup/master 合并githup上的master分支(两分支不是父子关系,所以合并需要添加 --allow-unrelated-histories)
    git push githup 推送同步到githup仓库
    展开
     1
     25
  • Santi
    2019-01-15
    fast forward到底是什么阿? 糊涂了,求老师讲解一下,谢谢

    作者回复: 举个例子,本地分支往远端分支做push,如果远端分支不是本地分支的祖先,那它俩就不是 fast forward 了。反之,它俩就是fast forward的关系。

     1
     7
  • 多多
    2018-12-30
    git remote add 后面使用的ssh协议,执行成功,但是在push的时候报错
    git@github.com: Permission denied (publickey).
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.
    使用http/https,push正常
    展开
     1
     3
  • pyhhou
    2019-01-03
    老师,想问个问题,对于private的仓库,即使加了access key,使用ssh的方式进行push会有以下的报错:
    repository access denied. access via a deployment key is read-only.
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

    但是如果不使用ssh的方式,转而用https的方式进行push的话,就没有这样的问题,是不是这里面有什么限制之类的?还请老师指点,谢谢老师,祝老师新年快乐
    展开

    作者回复: hi,估计您把公钥贴到仓库的deploy keys里面了,我们应该放到个人profile里SSH的设置中。

     1
     2
  • 齐庆福
    2019-07-16
    git fetch 拉取远程版本库到本地, 请问, 是将远程的代码拉取到工作区吗, 如果我之前工作区有新内容的话,然后 git fetch拉去远程代码到本地, 会不会发生覆盖行为呢

    作者回复: fetch不会拉到工作区的,只是把本地的远端分支和服务端对应的远端分支保持一致。

    建议你执行fetch测试一下。

    
     1
  • plasmatium
    2019-03-31
    关于其他同学遇到的ssh权限问题,我看到网上有个测试方法:`ssh -T git@github.com`,成功与否都会有相应提示。我一开始总报错denied,然后发现可以用`ssh -vT git@github.com`看具体发生了什么,发现ssh并没有使用我刚才生成的key,查了一圈,发现需要改`~/.ssh/config`这个文件。

    假设我们通过命令生成的是`my_key`和`my_key.pub`,那么可以添加如下信息到`~/.ssh/config`下:
    ```
    # gitee
    Host gitee.com
    HostName gitee.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/my_key

    # github
    Host github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/my_key
    ```
    此处我除了github,还另外添加了gitee,如果有其他服务器比如公司的仓库,也应该能一起添加进去的。然后确保github或者gitee上自己profile里ssh部分,添加了`my_key.pub`里面的公钥内容,那么此时用命令:`ssh -T git@github.com`,就报成功了。然后就可以愉快地用使用`git@github.com:xxx`的地址进行ssh通信了
    展开

    作者回复: 👍

    
     1
  • 时间的尘埃
    2019-01-24
    我执行只一句"$ git push --set-upstream github"
    报错:
    ssh_exchange_identification: read: Connection reset by peer
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    请教这是什么问题啊?
    展开
    
     1
  • Fairy
    2019-01-09
    老师 在不用merge用rebase的情况下怎么操作能说一下嘛?谢谢~

    作者回复: 1)先把远端的分支 fetch到本地,然后,再执行 rebase 。
    2)直接 git pull --rebase 。

     1
     1
  • TravelingLight
    2019-01-06
    github上建立仓库克隆到本地,这样建立连接不是很简单吗

    作者回复: 嗯,你提到的方式很好。当然有时候,也需要从本地同步到GitHub。

    
     1
  • Geek_4b1839
    2020-01-07
    老师,我配置完公钥之后,用git clone提示让输密码,这个是什么密码呢

    作者回复: 那说明公钥的方式没成功,可根据gitlab或github文档检查一下配置是否正确。

    
    
  • IvanYu
    2019-12-13
    老师,我们的工作场景比较特殊,有一个甲方和乙方共研项目。2个gitlab,其中甲方有内外网物理隔离,也就是说2个gitlab没法联网。
    目前采用git clone --bare {url}加U盘拷贝杀毒进入内网,再使用git push --mirror {url}方式全量同步到甲方gitlab。计划2周同步一次。
    这种方式存在共研后期分支代码合并问题,如何处理?
    请问是否有更好的解决方案。

    作者回复: 我们的做法是:为对外合作项目单独搭建了一个gitlab,公司内部员工用内网域名,合作方用外网域名,并且为外网IP设置了白名单,只有授权的IP才能访问公司的gitlab

    
    
  • l_j_dota_1111
    2019-07-23
    如果github上新建的仓库没有license文件,而是空的,在git上是不是能够直接push而不需要merge
    
    
  • iuSugar
    2019-05-23
    老师,我在本地连接了两次远程仓库(远程的是同一个),为远程仓库取了两个名字,一个是github,一个是origin,然后发现提交的分支也分为两个了,这么要怎么办呢?

    作者回复: 删掉一个多余的即可。大家可以用 git remote -h 看看该命令的使用说明,用 git remote remove github 就能把github删掉了。

    
    
  • BUGCREATOR
    2019-02-16
    老师,我在做练习的时候使用git clone "github的url"的形式从github上拉代码,没有用git remote add github https://gith...XXX.git的形式也可以将代码push到github上去 。 比较郁闷,用https协议提交的时候不用remote而是用ssh是时候要用remote吗?

    作者回复: remote add的方式是在当前路径下已经是git仓库的时候用的,为了让该git仓库可以push/pull不同的远端

    
    
  • 时间的尘埃
    2019-01-24
    回复一下我之前遇到的这个问题:
    ssh_exchange_identification: read: Connection reset by peer
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

    在.ssh文件下面应该会有个known_hosts文件,我这边是参照http://blog.51cto.com/abezoo/2089127给的解决方案,现在ok了,具体什么原因一知半解,老师能帮忙解答一下嘛,谢谢!
    展开
    
    
我们在线,来聊聊吧