Git新建本地分支與遠程分支關聯問題:git branch --set-upstream

Git新建本地分支與遠程分支關聯問題:git branch --set-upstream


git在本地新建分支, push到remote服務器上之後,再次pull下來的時候,如果不做處理會報以下提示:


You asked me to pull without telling me which branch you
want to merge with, and 'branch.production.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.
 
If you often merge with the same branch, you may want to
use something like the following in your configuration file:
 
    [branch "debug"]
    remote = <nickname>
    merge = <remote-ref>
 
    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>
 
See git-config(1) for details.


問題解析:

git本地新建一個分支後,必須要做遠程分支關聯。如果沒有關聯,git會在下面的操作中提示你顯示的添加關聯。關聯目的是如果在本地分支下操作: git pull, git push ,不需要指定在命令行指定遠程的分支.推送到遠程分支後,你只要沒有顯示指定,git pull的時候,就會提示你。


解決方法:

 使用命令git branch --set-upstream ;實例如下,其中debug爲創建的分支

git branch --set-upstream debug origin/debug


命令的最終修改都是針對config文件。

 

使用--set-upstream去跟蹤遠程分支。 

[core]
	repositoryformatversion = 0
	filemode = true
	bare = true
	logallrefupdates = true
[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:android2.3.5_r1.git
[branch "master"]
	remote = origin
	merge = refs/heads/master

[branch "debug"]
	remote = origin
	merge = refs/heads/debug

[receive]
denyCurrentBranch = ignore

注意倉庫.git目錄下的config文件




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章