重点是下面这个命令:
git branch --set-upstream-to=origin/one-branch one-branch
例如想把本地分支的 feature-983
跟进远程仓库的 feature-983
分支, 可以进行如下操作:
git branch --set-upstream-to=origin/feature-983 feature-983
下面是例子, 可以看到在执行 ... --set-upstream...
之前 Local branches configured for 'git pull':
下的列是没有 feature-983
的, 执行之后, 就有了.
Push URL: git@codehub.corp.com:group/oneService.git
HEAD branch: develop
Remote branches:
develop-983 tracked
feature-983 tracked
master tracked
Local branches configured for 'git pull':
develop-983 merges with remote develop-983
master merges with remote master
Local refs configured for 'git push':
develop-983 pushes to develop-983 (local out of date)
feature-983 pushes to feature-983 (up to date)
master pushes to master (up to date)
[~/workspace/topsale/oneService]$ git branch --set-upstream-to=origin/feature-983 feature-983 *[feature-983]
Branch feature-983 set up to track remote branch feature-983 from origin.
[~/workspace/topsale/oneService]$ git remote show origin *[feature-983]
* remote origin
Fetch URL: git@codehub.corp.com:group/oneService.git
Push URL: git@codehub.corp.com:group/oneService.git
HEAD branch: develop
Remote branches:
develop-983 tracked
feature-983 tracked
master tracked
Local branches configured for 'git pull':
develop-983 merges with remote develop-983
feature-983 merges with remote feature-983
master merges with remote master
Local refs configured for 'git push':
develop-983 pushes to develop-983 (local out of date)
feature-983 pushes to feature-983 (up to date)
master pushes to master (up to date)