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
- 从上游仓库获取到分支,及相关的提交信息,它们将被保存在本地的
upstream/master
分支 - 在你本地的
master
分支上,将合并后的信息提交 -
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