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

转载地址:如何同步 Github fork 出来的分支

git remote add upstream [email protected]:original_owner/original_repository.git
git fetch upstream
git merge upstream/master
git commit -m "message"
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.

原来是因为没有 commitDealing with non-fast-forward errors

猜你喜欢

转载自blog.csdn.net/zhangge3663/article/details/84064315