与上游仓库保持同步 Git-Workflow
How to sync a fork with an upstream
检查本地仓库的远程配置
git remote -v
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
添加上游远程仓库
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
git remote -v
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
同步fork仓库
git checkout master
Switched to branch 'master'
git fetch upstream
git merge upstream/master
请注意
merge
和rebase
的区别
本文采用 知识共享署名 4.0 国际许可协议(CC-BY 4.0)进行许可。转载请注明来源: https://snowfrs.com/2016/09/07/git-workflow-fork.html 欢迎对文中引用进行考证,欢迎指出任何不准确和模糊之处。