git 推送本地分支到远程 并添加分支关联跟踪

本地新建分支推送到远程上

1、查看全部分支

git branch -al

git 推送本地分支到远程 并添加分支关联跟踪_第1张图片

带星号的是当前的本地分支, origin 的是远程分支。

git push origin 本地分支:远程分支

比如吧1.0.2 推送到远程

git push origin 1.0.2:1.0.2
warning: redirecting to https://........api.git/
Total 0 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for 1.0.2, visit:
remote:   https://........%5Bsource_branch%5D=1.0.2
remote:
To https://.........api
 * [new branch]          1.0.2 -> 1.0.2

查看一下是否成功:

git 推送本地分支到远程 并添加分支关联跟踪_第2张图片

设置关联跟踪:

当使用新建分支git pull 时会提示:

git:(1.0.2) ✗ git pull
warning: redirecting to https://........api.git/
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull  

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/ 1.0.2

    git branch --set-upstream-to=origin/ 1.0.2

解释: git branch --set-upstream-to=origin/远程分支名 1.0.2

git:(1.0.2) ✗ git branch --set-upstream-to=origin/1.0.2 1.0.2
Branch '1.0.2' set up to track remote branch '1.0.2' from 'origin'.

再次尝试:

git:(1.0.2) ✗ git pull
warning: redirecting to https://.......api.git/
Already up to date.

就很棒

你可能感兴趣的:(git,git,分支)