Set Git Tracking Branch on `push`
You hate this error, right?
$ git push There is no tracking information for the current branch.
I especially hate
git's recommendation at this stage:
$ git branch --set-upstream-to=origin/<branch> my-branch
You can check for tracking information in your config file with:
$ git config -l | grep my-branch # returns exit code 1 (nothing)
Yep, no tracking info. The first time you push you should use the -u flag.
# assuming you are on my-branch $ git push -u origin HEAD
No do you have tracking info?
# returns the tracking information stored in config! $ git config -l | grep my-branch branch.my-branch.remote=origin branch.my-branch.merge=refs/heads/my-branch branch.my-branch.rebase=true
Did you forget to set up tracking on the first push? Don't worry, this actually works anytime you push.
$ git push There is no tracking information for the current branch. $ git push -u origin HEAD Branch 'my-branch' set up to track remote branch 'my-branch' from 'origin' by rebasing.
This is so more ergonomic than