Auto setup remote branch and never again see an error about the missing upstream
A little git tip published on Twitter by James Ide went viral a few days ago, and it inspired me to write down this post. You usually see this when you try to git push
a local branch that misses a remote upstream.

In most cases, something that we need in this case is to push the current branch to the remote repository under the same branch name. Luckily we have two helpful configuration options to do it.
git config --global --add push.default current
git config --global --add push.autoSetupRemote true
Setting any of these confuguration options (push.default
or push.autoSetupRemote
) will automatically push to the receiving end a branch with the same name. Additionally, push.autoSetupRemote
(added to git 2.37.0) sets the upstream tracking to the corresponding branch.
No more git push --set-upstream origin test && git push
again! Bye 👋
It's crazy how a tool you use every day can have such amazing features without you knowing. Thank you for sharing, you just improved my git workflow :)
Comments like this one, motivate me to keep on writing. Thanks Nick!
Thanks for this, this helps a good bit in improving my git workflow :)
Thank you for this! That's so much value in such a short post, absolutely perfect :-)
Thank you! I was unclear on how to do this but this breakdown is perfect!
Awww 🤗 I am glad you found it helpful!
Awesome! Thank you very much!
I am glad it helped you out 🤗
Awesome !!! Get it! Thanks a lot
"git config --global --add push.default current" worked for me. Thanks a lot =)