fork项目后与原项目保持同步

225 阅读1分钟

来源自我的博客

参考链接

将远程原始repo合并到远程fork repo的本地repo后推送到远程fork repo

  1. clone远程fork repo
  2. 添加远程原始repo为upstream
  3. fetch&merge远程原始repo的分支到本地分支
  4. push到远程fork repo分支

具体操作

  1. Set up Git
  2. Create a local clone of your fork
git clone https://github.com/YOUR-USERNAME/REPO_NAME.git
  1. Configure Git to sync your fork with the original repository
# check the current configured remote repository for your fork.
git remote -v
# add upstream
git remote add upstream https://github.com/ORIGINAL-USERNAME/REPO_NAME.git
# verify the new upstream repository
git remote -v
  1. Fetch and merge original repository into your local repository
git fetch upstream
git merge upstream/master
  1. push to your remote fork repo
git push origin master