LoginSignup
5
3

More than 3 years have passed since last update.

ブランチ名を省略したgit pull が通らない時の対処

Posted at

ブランチ名を省略した git pull コマンドで以下のエラーに遭遇するときがある。

$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

即刻pullしたいのであれば、git pull origin masterと打ち直すのが解決策としては早い。

が、そもそもの原因としてカレントブランチのupstreamが解決されていないことを解決してやれば、
ブランチ名を省略してシンプルに git pull とコマンドを打つだけで済むようになる。

なんでも省略できるものはした方が作業効率がよいので対処する。
ログ後半の推奨コマンドに従えばよく、例えばmasterブランチにいるのならば以下コマンドを実行する。

$ git branch --set-upstream-to=origin/master master

このコマンドを実行すると、.git/config内に以下が追記される。

~/.git/config
[branch "master"]
    remote = origin
    merge = refs/heads/master

マージ参照先が追記されていることが確認できる。

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3