目的

gitで新規branchを作ってpushしようとすると git push --set-upstream origin new-branch-name しろと言われる。 これをしなくても新規で作ったbranchをデフォルトpush先と指定したかった。

対応

新しいブランチを push したときに自動的に --set-upstream を設定するように global setting を指定する。

git config --global push.autoSetupRemote true

設定&実行sample

> git config --global push.autoSetupRemote true

> git push

〜略〜

remote:
To github.com:username/RepositoryName.git
 * [new branch]      new-branch-name -> new-branch-name
branch 'new-branch-name' set up to track 'origin/new-branch-name'.

この設定で、新しいブランチを作成後に git push するだけで --set-upstream を省略できるようになる。