Git-将本地分支推到远程,并使本地分支跟踪该远程分支



我最近开始使用GIT命令行命令(我以前使用SourceTree)。

当我想创建一个新分支时,我通常会执行git checkout -b <branch-name>。当我想把它推到远程时,我会做git push origin <branch-name>

现在,在我将这个本地分支推送到远程之后,我如何使我的本地分支跟踪这个远程分支?(我不希望我的本地分支跟踪master)

使用-u:

$ git push -u origin localname:remotename

$ git help push
...  
 -u, --set-upstream
       For every branch that is up to date or successfully pushed, add
       upstream (tracking) reference, used by argument-less git-pull(1)
       and other commands. For more information, see branch.<name>.merge
       in git-config(1).

最新更新