2.

現在のブランチはプル用に構成されていません 構成にキー remote.origin.url の値がありません

編集
この記事の要点
  • 現在のブランチはプル用に構成されていませんgit pull するブランチに upstream 設定がないエラー
  • 対処 ①: git branch --set-upstream-to=origin/main main
  • 対処 ②: git pull origin main でリモート明示
  • 対処 ③: git push -u origin main で push 時に upstream 自動設定
  • 初心者向けに git config --global push.autoSetupRemote true も便利

 

エラーの状況

$ git pull
現在のブランチはプル用に構成されていません。
変更を統合するためには、以下を行ってください
    git pull <リモート> <ブランチ>
さもなければ
    git branch --set-upstream-to=<リモート>/<ブランチ> <ブランチ>

# 英語版
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull  

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

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

原因

git pull は「現在のブランチに対応するリモートブランチ」(upstream / tracking branch) から fetch + merge します。upstream が設定されていないと「どのリモートブランチを pull するか」が分からずエラーになります。

upstream 設定の確認

# 現在の upstream
$ git branch -vv
* feature/login  abc1234 [origin/feature/login] commit message
  main           def5678 [origin/main]          another commit
  local-only     ghi9012                        ← upstream なし

# git remote 設定
$ git remote -v
origin  git@github.com:user/repo.git (fetch)
origin  git@github.com:user/repo.git (push)

対処方法

方法 1: upstream を後から設定(推奨)

# 現在のブランチに upstream 設定
$ git branch --set-upstream-to=origin/main main
branch 'main' set up to track 'origin/main'.

# 短縮形
$ git branch -u origin/main

# 確認
$ git branch -vv
* main  abc1234 [origin/main] commit message

# 以後は普通に pull
$ git pull

方法 2: pull 時にリモートとブランチを明示

$ git pull origin main
# remote = origin, branch = main を明示

# 短縮 (1 回だけならこれで OK)
# 毎回打つのは面倒 → upstream 設定を推奨

方法 3: push 時に -u で upstream 自動設定

# 新規ブランチを push しつつ upstream 設定
$ git push -u origin feature/new-feature

# = git push origin feature/new-feature + git branch -u origin/feature/new-feature

# 以後は普通に push / pull できる
$ git push
$ git pull

方法 4: グローバル設定で自動 upstream(推奨)

# 新規ブランチを push する時、自動的に upstream 設定
$ git config --global push.autoSetupRemote true

# 以後は push で -u 不要
$ git checkout -b new-feature
$ git push  # → 自動的に origin/new-feature 作成 + upstream 設定

# Git 2.37+ で利用可能

状況別の対応

シナリオ 1: ローカルだけのブランチをリモートにプッシュ

# ローカルで作ったブランチ
$ git checkout -b feature/dashboard

# コミット
$ git add .
$ git commit -m "add dashboard"

# 初回 push (upstream 設定)
$ git push -u origin feature/dashboard

# 以後は普通に
$ git push
$ git pull

シナリオ 2: クローン直後で upstream 設定が消えた

# clone なら upstream は自動設定されているはず
$ git clone https://github.com/user/repo.git
$ cd repo
$ git pull  # → OK

# それでもエラーなら fetch 確認
$ git fetch origin
$ git branch -r  # リモートブランチ一覧
$ git branch --set-upstream-to=origin/main main

シナリオ 3: ローカルとリモートで名前が違うブランチ

# ローカル: feature/login
# リモート: features/login (s 違い)

# 明示的にマッピング
$ git branch --set-upstream-to=origin/features/login feature/login

# または fetch + checkout
$ git fetch origin features/login:feature/login

シナリオ 4: 別リポジトリの fork から pull

# 自分の fork: origin
# 元リポジトリ: upstream として追加
$ git remote add upstream https://github.com/original/repo.git

# upstream から pull
$ git fetch upstream
$ git merge upstream/main

# または直接
$ git pull upstream main

関連 git config 設定

# 新規ブランチに自動 upstream
$ git config --global push.autoSetupRemote true

# pull のデフォルト動作 (merge / rebase)
$ git config --global pull.rebase false   # merge (デフォルト)
$ git config --global pull.rebase true    # rebase
$ git config --global pull.ff only        # fast-forward only

# branch.autoSetupMerge (新規ブランチ作成時)
$ git config --global branch.autoSetupMerge always
# true (デフォルト): リモートから派生したブランチのみ自動 tracking
# always: ローカル間でも自動 tracking
# false: 自動 tracking なし

# 設定確認
$ git config --list | grep -E "push|pull|branch"

upstream / tracking branch の概念

# upstream = 「このローカルブランチが追従するリモートブランチ」
# 設定済みの利点:
# - git pull / git push に引数不要
# - git status で「ahead of origin/main by 3 commits」と表示
# - git fetch でリモートの最新を取り込みやすい

# 確認コマンド
$ git config branch.main.remote     # → origin
$ git config branch.main.merge      # → refs/heads/main

# 削除
$ git branch --unset-upstream
# またはコンフィグから
$ git config --unset branch.main.remote
$ git config --unset branch.main.merge

関連エラー

エラー意味
current branch has no tracking branchこのページ
The current branch master has no upstream branchpush 時の同種エラー
fatal: not a git repositorygit 管理外
fatal: refusing to merge unrelated histories履歴非共通

関連記事

編集
Post Share
子ページ

子ページはありません

同階層のページ
  1. モジュール名が無効です。(WAR エクスポート)
  2. 現在のブランチはプル用に構成されていません 構成にキー remote.origin.url の値がありません
  3. サーバーに追加または除去できるリソースがありません。
  4. invalid LOC header (bad signature)