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する

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2020-08-27 (木) 00:34:45