2013-11-20 276 views
0

我最近開始使用GIT命令行命令(我曾經使用SourceTree)。Git - 將本地分支推送到遠程並使本地分支跟蹤遠程分支

當我想創建一個新的分支時,我通常會做git checkout -b <branch-name>。 當我想把它推到遠程時,我會做git push origin <branch-name>

現在,我已經推動這個本地分支到遠程後,我該如何讓我的本地分支跟蹤這個遠程分支? (我不希望我的本地分支跟蹤主)

回答

2

使用-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). 
+0

奏效!謝謝!! – learner2010

相關問題