push時に--set-upstreamを聞かれるのを省略する
現象
$ git branch branch1
$ git co branch1
(略)
$ git commit -m 'N/A'
$ git push
fatal: The current branch branch1 has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin branch1
- 新規ブランチ(ここではbranch1)を作って、何かしらコミット後にgit pushすると、リモートブランチを指定してないので、上のようなエラーメッセージが表示される
- git push --set-upstream origin branch1としてpushすればいいが、毎回面倒なので省略したい
リモートブランチ名を現在のローカルのブランチ名にする
$ git config push.default current
(または git config --global push.default current )
$ git push
- 上のようなコマンドで.gitconfig(.git/config)に設定をした後、pushする