1. 程式人生 > >將fork出來的分支與原專案合併

將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