2017-02-10 57 views
0

每一次,當我要推,我用這個命令:如何配置我的git進行推送?

$ git push 

它拋出這個錯誤:

fatal: The current branch master has no upstream branch. 
To push the current branch and set the remote as upstream, use 

    git push --set-upstream origin master 

當我使用這個命令的錯誤將會消失:

$ git push origin master 

好吧,我可以隨時使用這個^命令,但我想knon,我可以說的Git,{當我說push,我的意思是push origin master}一次永遠?

回答

0

一旦你給你的本地分支上游

git push --set-upstream origin master 

那之後,下面將「只是工作」

git push 

你只需要做的第一個命令,如果遠程分支呢尚不存在。

要檢查您是否已經跟蹤遠程分支您可以鍵入

git branch -vv 

然後,它會列出類似

master abcd123 [origin/master] Some commit message 

然後你就可以看到你的本地master分支追蹤遠程origin/master分支。

+0

我怎麼理解「遠程分支是否存在」? –

+0

@MartinAJ:參見http://stackoverflow.com/q/21609781/1256452 – torek

1

,或者你可以使用這個符號的短版:

git push --set-upstream origin <REMOTE_NAME> 

git push -u origin <REMOTE_NAME> 

混帳需要知道哪些遠程分支您正在嘗試把你的代碼。

+0

謝謝.. upvote –