git upstream 相关操作

561 阅读1分钟
  • 添加upstream
git remote add upstream xxxxx(upstream地址)
  • 查看
$ git remote -v 

origin	ssh://xxx (fetch)
origin	ssh://xxx (push)
upstream	ssh://yyy (fetch)
upstream	ssh://yyy (push)
  • 取消
git branch --unset-upstream
  • 拉取
$ git fetch upstream(会把上游仓库的所有分支与tag拉取到本地)
$ git checkout master
$ git rebase upstream/master

或者拉取某一个具体分支

git pull upstream master
  • 根据上游分支创建本地分支
git fetch upstream
git checkout -b newbranch upstream/newbranch
git push -u origin newbranch