git checkout tag, git pull fails in branch

2020-05-11 04:34发布

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..

14条回答
神经病院院长
2楼-- · 2020-05-11 05:10

Try these commands:

git pull origin master
git push -u origin master
查看更多
Evening l夕情丶
3楼-- · 2020-05-11 05:11

First, make sure you are on the right branch.
Then (one time only):

git branch --track

After that this works again:

git pull
查看更多
登录 后发表回答