git pullができないときの解決方法メモ
git pullしたらこんなエラーになってpullできない
$ git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.branch_name.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 "branch_name"]
remote = <nickname>
merge = <remote-ref>
[remote "<nickname>"]
url = <url>
fetch = <refspec>
See git-config(1) for details.
git remote show originを見ると、適当に変えてますがこんな結果に
$ git remote show origin
* remote origin
Fetch URL: https://github.com/xxxxxxxxx/xxxxxxx.git
Push URL: https://github.com/xxxxxxxxx/xxxxxxx.git
HEAD branch: master
Remote branches:
branch_name tracked
master tracked
Local branches configured for 'git pull':
master merges with remote master
Local refs configured for 'git push':
branch_name pushes to branch_name (local out of date)
master pushes to master (up to date)
branch_nameブランチのpush先のブランチ名は「Local refs configured for 'git push':」で設定されているが
pull元のブランチ名が「Local branches configured for 'git pull':」で設定されていないのが原因。
branch_nameブランチは、ローカルで作成してpushしたブランチで、cloneして作成したブランチでないので、こういう状況になってる。
解決方法としては、pull元のブランチ名を設定してやればいい
$ git config branch.branch_name.merge refs/heads/branch_name $ git config branch.branch_name.remote origin
これでgit pullできるようになる
git remote show originの結果は以下のようになる
$ git remote show origin
* remote origin
Fetch URL: https://github.com/xxxxxxxxx/xxxxxxx.git
Push URL: https://github.com/xxxxxxxxx/xxxxxxx.git
HEAD branch: master
Remote branches:
branch_name tracked
master tracked
Local branches configured for 'git pull':
branch_name merges with remote branch_name
master merges with remote master
Local refs configured for 'git push':
branch_name pushes to branch_name (up to date))
master pushes to master (up to date)git不安