git checkout tag, git pull fails in branch

后端 未结 14 566
渐次进展
渐次进展 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:04

    This command is deprecated: git branch --set-upstream master origin/master

    So, when trying to set up tracking, this is the command that worked for me:

    git branch --set-upstream-to=origin/master master
    
    0 讨论(0)
  • 2021-01-29 23:06

    Try these commands:

    git pull origin master
    git push -u origin master
    
    0 讨论(0)
  • 2021-01-29 23:08

    You need to set up your tracking (upstream) for the current branch

    git branch --set-upstream master origin/master
    

    Is already deprecated instead of that you can use --track flag

    git branch --track master origin/master
    

    I also like the doc reference that @casey notice:

    -u <upstream>
      Set up <branchname>'s tracking information so <upstream> is considered  
      <branchname>'s upstream branch. If no <branchname> is specified,  
      then it defaults to the current branch.
    
    0 讨论(0)
  • 2021-01-29 23:12

    I had the same problem and fixed it with this command:

    $ git push -u origin master
    

    From the help file the -u basically sets the default for pulls:

    -u, --set-upstream`
    
      For every branch that is up to date or successfully pushed, add 
      upstream (tracking) reference, used by argument-less git-pull(1) and
      other commands. For more information, see branch.<name>.merge in 
      git-config(1).
    
    0 讨论(0)
  • 2021-01-29 23:14

    If like me you need to do this all the time, you can set up an alias to do it automatically by adding the following to your .gitconfig file:

    [alias]
        set-upstream = !git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`
    

    When you see the message There is no tracking information..., just run git set-upstream, then git push again.

    Thanks to https://zarino.co.uk/post/git-set-upstream/

    0 讨论(0)
  • 2021-01-29 23:15

    In order to just download updates:

    git fetch origin master
    

    However, this just updates a reference called origin/master. The best way to update your local master would be the checkout/merge mentioned in another comment. If you can guarantee that your local master has not diverged from the main trunk that origin/master is on, you could use git update-ref to map your current master to the new point, but that's probably not the best solution to be using on a regular basis...

    0 讨论(0)
提交回复
热议问题