設定しておくとちょっと便利なgit config、3選

2024/07/20に公開

push.autoSetupRemote

設定
git config --global push.autoSetupRemote true

ブランチの初回プッシュ時に、リモートブランチを指定しなくても自動で設定されるようになります。

設定前

新しく作ったブランチをプッシュするとき
git push -u origin branch-name
# もしくは
git push -u origin HEAD

設定後

新しく作ったブランチをプッシュするとき
git push

push.followTags

設定
git config --global push.followTags true

git pushを実行した際に、 タグも同時にプッシュしてくれるようになります。

設定前

タグ付けしたコミットをプッシュするとき
git push && git push --tags
# もしくは
git push --follow-tags

設定後

タグ付けしたコミットをプッシュするとき
git push

commit.verbose

設定
git config --global commit.verbose true

エディタでコミットメッセージを書いている人向け(git commit-mオプションを付けない人向け)です。コミットの差分を見ながらコミットメッセージを書けるようになります。

設定前

設定後

おわりに

おすすめの設定が他にもあれば、ぜひ教えてください!

Discussion