How to configure git to auto-setup a remote tracking branch?

Hello and welcome back to my blog! Today we're going to look at a rather simple command that will save you a small amount of time every time you push a feature branch to remote!

Usually, when you create a new local git branch and are ready to push upstream, you might encounter the following message if you simply commit and issue a git push:

thenetworkhippo@dev-machine$ git push
fatal: The current branch the-network-hippo-branch has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin the-network-hippo-branch

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

A simple configuration to have git automatically setup your remote tracking branch is:

git config --global --add --bool push.autoSetupRemote true

And that's it! Now you can simply use git push all the time and let git worry about setting up the remote tracking branch for your first push!

Hope this helps! :)

Next
Next

Understanding the hardware production lifecyle