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


本文轉載自:http://blog.csdn.net/netwalk/article/details/21088405

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

 

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

 

 

[html]  view plain  copy
 
  1. You asked me to pull without telling me which branch you  
  2. want to merge with, and 'branch.production.merge' in  
  3. your configuration file does not tell me, either. Please  
  4. specify which branch you want to use on the command line and  
  5. try again (e.g. 'git pull <repository<refspec>').  
  6. See git-pull(1) for details.  
  7.    
  8. If you often merge with the same branch, you may want to  
  9. use something like the following in your configuration file:  
  10.    
  11.     [branch "debug"]  
  12.     remote = <nickname>  
  13.     merge = <remote-ref>  
  14.    
  15.     [remote "<nickname>"]  
  16.     url = <url>  
  17.     fetch = <refspec>  
  18.    
  19. See git-config(1) for details.  

 

 

問題解析:

 

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

 

解決方法:

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

 

[html]  view plain  copy
 
  1. git branch --set-upstream debug origin/debug  



 

 

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

 

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

 

[html]  view plain  copy
 
  1. [core]  
  2.     repositoryformatversion = 0  
  3.     filemode = true  
  4.     bare = true  
  5.     logallrefupdates = true  
  6. [remote "origin"]  
  7.     fetch = +refs/heads/*:refs/remotes/origin/*  
  8.     url = git@192.168.1.160:android2.3.5_r1.git  
  9. [branch "master"]  
  10.     remote = origin  
  11.     merge = refs/heads/master  
  12.   
  13. [branch "debug"]  
  14.     remote = origin  
  15.     merge = refs/heads/debug  
  16.   
  17. [receive]  
  18. denyCurrentBranch = ignore  


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

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM