Git建立本地分支與遠程分支關聯問題:git branch

來源:互聯網
上載者:User

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


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


You asked me to pull without telling me which branch youwant to merge with, and 'branch.production.merge' inyour configuration file does not tell me, either. Pleasespecify which branch you want to use on the command line andtry again (e.g. 'git pull <repository> <refspec>').See git-pull(1) for details. If you often merge with the same branch, you may want touse 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 = 0filemode = truebare = truelogallrefupdates = true[remote "origin"]fetch = +refs/heads/*:refs/remotes/origin/*url = git@192.168.1.160:android2.3.5_r1.git[branch "master"]remote = originmerge = refs/heads/master[branch "debug"]remote = originmerge = refs/heads/debug[receive]denyCurrentBranch = ignore

注意倉庫.git目錄下的config檔案




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.