將fork出來的分支與原專案合併
阿新 • • 發佈:2018-11-14
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
- 從上游倉庫獲取到分支,及相關的提交資訊,它們將被儲存在本地的
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