Fix for the current branch has no upstream branch error message

Posted by Stephen Petrey on Friday, April 7, 2023

This is one of those git config things you set once and forget years later when you setup a new machine. How did we get here? You can git push expecting to fly up to the remote repository right?

fatal: The current branch feature-1234 has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin feature-1234

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

To get rid of this message forever and prevent git from gatekeeping you just run this:

git config --global push.default current

This will set your git config to only push your current branch when running git push. Enjoy never having to worry about this again!

Discussion

Leave a Comment