git checkout tag, git pull fails in branch

alesko picture alesko · Apr 13, 2012 · Viewed 124.6k times · Source

I have cloned a git repository and then checked out a tag:

# git checkout 2.4.33 -b my_branch

This is OK, but when I try to run git pull in my branch, git spits out this error:

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 new origin/<branch>

I want git pull to only update the master branch and leave my current branch alone (it's a tag anyway). Is something like this possible?

The reason I need this is that I have a automatic script which always git pulls the repository and of course fails because of the error above..

Answer

Vincent Wen picture Vincent Wen · Apr 11, 2013

Edit: For newer versions of Git, --set-upstream master has been deprecated, you should use --set-upstream-to instead:

git branch --set-upstream-to=origin/master master

As it prompted, you can just run:

git branch --set-upstream master origin/master

After that, you can simply run git pull to update your code.