Git pull 从别人的fork

标签 git git-commit git-push git-pull git-fork

我们是两个学生,致力于我们的在线存储库(不同的存储库),该存储库是从一个共同的上游存储库派生出来的。

假设其他学生在特定分支上对他的存储库进行了更改、提交和推送。

  1. 如何将这些更改 pull 入我自己的本地存储库?

  2. 我是否需要将这些更改提交并推送到我的临时区域?

谢谢!

最佳答案

在你的 other 中添加一个新的 Remote (比如 own ) repo 。 pull other/<branch>更改为您的本地分支机构(例如 add-other-changes )。推送到您自己的 fork repo ( origin/add-other-changes )。现在,你什么时候完成 add-other-changes分支,创建一个 pull 请求并将其与 origin/master merge .

  • 将其他仓库的更改 pull 入您自己的仓库:

      # go into your own repo
      $ git remote add other <other-student-repo-url>  # add a new remote with other's repo URL
    
      $ git fetch other         # sync/update local with other's repo
    
      $ git checkout -b add-other-changes       # create a new branch named 'add-other-changes'                    
      $ git pull other <specific-branch-name>   # pull other/<branch> changes           
    
      $ git push origin HEAD    # push changes to your own(origin) forked repo `add-other-changes` branch
    

关于Git pull 从别人的fork,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42156971/

相关文章:

git - Bitbucket 文档在撒谎

git rebase master 特性给出(重命名/删除)冲突,git rebase -i master 特性没有

git merge 重复冲突

git - Perl -- commit-msg 钩子(Hook)在退出时不会停止提交 1

git - 我可以为 git 使用脚本化提交模板吗?

git - 强制 "git push"覆盖远程文件

linux - IdentityFile 在 ssh 配置中被忽略

git - 为什么恢复的提交不会显示在新的 PR 中?

windows - TortoiseGit 错误 : "Remote name must not be empty"

git push 'pushing'不是新分支