Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

automatically create --set-upstream origin doing git push

Tags:

git

github

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?

like image 415
Alicia Y Avatar asked Apr 14 '26 23:04

Alicia Y


2 Answers

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.

like image 91
philb Avatar answered Apr 17 '26 13:04

philb


With the release of git 2.37 in June 2022, you can do so with push.autoSetupRemote

git config --global push.autoSetupRemote true
like image 38
Ru Chern Chong Avatar answered Apr 17 '26 14:04

Ru Chern Chong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!