LoginSignup
283
269

More than 5 years have passed since last update.

git push時に表示されるwarning: `push.default is unset...`の意味と解決方法

Last updated at Posted at 2012-12-26

(おそらく)git v1.8から以下のようなメッセージが出るようになった人は多いと思います.この意味を解説します.

$ g push         
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

push.default: simple? matching?

push.defaultは,git push時にrefspec(ブランチ名やタグ名)を指定しなかったときの挙動を設定する.(例えばgit push, git push originとしたとき)
push.defaultのデフォルト設定がGit 2.0でmatchingからsimpleに代わる.

simple

現在のブランチをupstreamのブランチにpushする.ただしupstreamのブランチ名が現在のブランチと異なる場合はpushしない.
"This is the safest option and is well-suited for beginners."とのこと.あまり起きなさそうだけど,間違ったブランチをtrack設定してしまったときなどはpushできないので安全?

matching

git push時に同名のブランチ(=マッチするブランチ)をそれぞれpushする.いままでのデフォルト.

その他

push.defaultに設定できる値としては以下がある.

  • nothing
    • pushしない.つまり必ずgit push origin masterのようにrefsを指定する必要がある.
  • current
    • 現在のブランチを同名のリモートブランチにpushする.
  • upstream
    • 現在のブランチをupstreamのブランチにpushする.

結論

warningの通り,いまのgitの挙動を保ちたいならmatching,現在のbranchのみ安全にpushしたいならsimpleにするとよい.

git config --global push.default matching
# or
git config --global push.default simple
283
269
1

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
283
269