git pull沒有指定branch報錯

當我們使用如下命令檢出開發分支:

git checkout -v dev

然後再dev分支上git pull時候經常報如下錯誤:

HEAD is now at 990a248 Merge branch 'dev' of git.avlyun.org:userc/new-6xx into dev
You asked me to pull without telling me which branch you
want to merge with, and 'branch.dev.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 "dev"]
    remote = <nickname>
    merge = <remote-ref>

    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>

當你從遠程倉庫克隆時,實際上Git自動把本地的master分支和遠程的master分支對應起來了,並且,遠程倉庫的默認名稱是origin,所以在master分支時,使用git pull一般都不會報錯,這時候需要將dev分支關聯到遠程分支:

git branch --set-upstream dev origin/dev

關聯之後,再使用git pull不會出現以下問題

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