Automatically --set-upstream when pushing a new branch

howto git

2019-04-08


I frequently open a new branch with git flow, and the first time I push to Github, I see the following message:

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

    git push --set-upstream origin feature/whatever

It seems redundant that git offers me a solution and then makes my type it myself (especially considering the solution, to use --set-upstream, is actually deprecated). This finally annoyed me enough to figure out how to remedy this:

$ git config --global push.default current

Now to push to a new branch for the first time, just do this:

$ git push -u