No More “git push — set-upstream origin new-branch”

Tom Smykowski
1 min readSep 28, 2023

If you’re using GIT, you surely know that after creating a new branch locally:

git checkout -b new-branch

And committing your changes, you still have to create the remote branch respectfully with:

git push --set-upstream origin new-branch

It’s quite annoying because GIT should know that we want to do it anyway. Fortunately it changed with Git 2.37. To check your version of Git type:

git --version

If your version is older, update it. But it’s not all. You have also set up a special parameter:

git config --global push.autoSetupRemote true

The parameter is widely undocumented. It’s surprisingly given how important it is.

After setting up the parameter, all you have to do is:

git push

GIT will figure out you want to create an upstream branch. Less writing makes me happy :)

Follow, clap, comment for more coding articles!

--

--

Tom Smykowski
Tom Smykowski

Written by Tom Smykowski

Software Engineer & Tech Editor. Top 2% on StackOverflow, 3mil views on Quora. Won Shattered Pixel Dungeon.

Responses (3)