git checkout tag, git pull fails in branch

后端 未结 14 891
渐次进展
渐次进展 2021-01-29 22:51

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<

14条回答
  •  北恋
    北恋 (楼主)
    2021-01-29 23:21

    You could specify what branch you want to pull:

    git pull origin master
    

    Or you could set it up so that your local master branch tracks github master branch as an upstream:

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

    This branch tracking is set up for you automatically when you clone a repository (for the default branch only), but if you add a remote to an existing repository you have to set up the tracking yourself. Thankfully, the advice given by git makes that pretty easy to remember how to do.

    --set-upstream is deprecated in git 1.9.x, apparently. Going forward you'd want to use something like

    git branch -u origin/master
    

    assuming you've checked out master already. If not, git branch -u origin/master master will work

提交回复
热议问题