将 fork 出来的分支与原项目合并

如何同步 Github fork 出来的分支

1. git remote add upstream  git@github.com:original_owner/original_repository.git
2. git fetch upstream
3. git merge upstream/master
4. git commit -m "message"
5. git push origin master    
  1. 从上游仓库获取到分支,及相关的提交信息,它们将被保存在本地的 upstream/master 分支
  2. 在你本地的 master 分支上,将合并后的信息提交
  3. push 到你远程的仓库

我在最后一步 push 的时候报错:

$ git push origin master
To https://github.com/USERNAME/REPOSITORY.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/USERNAME/REPOSITORY.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

原来是因为没有 commit, Dealing with non-fast-forward errors

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容