本地新建分支推送到远程上
1、查看全部分支
git branch -al
带星号的是当前的本地分支, 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 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 <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> 1.0.2
git branch --set-upstream-to=origin/<branch> 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.
就很棒