When working with Git and you run
git pull sometimes this error message occurs.
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch –set-upstream-to=<remote>/<branch> mybranch
Note: In the last line
mybranch will likely be a different value, this is the name of the current branch you are on.
The Quick Fix
Over 99% of the time running the following corrects this problem for me.
git branch --set-upstream-to=origin/$(git symbolic-ref --short HEAD)
I even have a git alias setup to run this line for me. After this,
git pull should work successfully.
What is the Problem
Why does the “There is no tracking information for the current branch.” error occur in the first place?
When you run
git pull, Git tries to pull any changes from the remote copy of the branch (on a server like GitHub, GitLab, or Bitbucket) into your local branch. The “There is no tracking information for the current branch.” occurs when Git doesn’t know which branch on the server if should pull from.
Almost always you want to pull from the branch on the server
origin with the same name as your local branch (
mybranch). The Quick Fix above sets Git to do exactly this.
When you run the quick fix, it adds the following to your project
[branch "mybranch"] remote = origin merge = refs/heads/mybranch
Slightly Longer Fix You Can Memorize
While I’m sure you enjoy visiting this webpage, if you want to be able to solve this issue without referring to instructions this set of steps does the same thing as the one-line quick fix but is easier to remember.
- Copy the last line of the error message.
git branch --set-upstream-to=<remote>/<branch> mybranch
mybranchthe last section will be the name of your current Git branch
- Using the arrows and Backspace key, replace
<remote>/<branch>from the middle of the command with
origin/, the result should look something like
git branch --set-upstream-to=origin/mybranch