delhi09の勉強日記

技術トピック専用のブログです。自分用のメモ書きの投稿が多いです。あくまで「勉強日記」なので記事の内容は鵜呑みにしないでください。

新規ブランチのpush時に--set-upstream origin xxxを省略する

今まで、新規ブランチのpush時に一旦git pushして、以下のようなエラーが出て怒られてからgit push --set-upstream origin xxxをコピペして実行するということをしていました。

fatal: The current branch xxx has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin xxx

以下のコマンドを実行して設定しておくと、新規ブランチでもgit push xxxだけでpushできることを知りました。

git config --global push.autoSetupRemote true