Reputation: 387
It's annoying I got prompt every time trying to push new branch. For instance, I do this
git checkout -b myBranch
git add . && git commit -m 'first commit'
git push
but I got this
git push --set-upstream origin myBranch
is there anyway to skip this?
Upvotes: 10
Views: 5568
Reputation: 3756
With the release of git 2.37 in June 2022, you can do so with push.autoSetupRemote
git config --global push.autoSetupRemote true
Upvotes: 7
Reputation: 2990
You can configure Git with these settings:
git config --global push.default current
git config --global remote.pushDefault origin
and then you can simply use:
git push
to push the curent branch to a branch with the same name on the remote origin
. This does not set the upstream configuration, but it does allow you to push without any other arguments, whether it’s the first time you are pushing a branch or not.
Upvotes: 20