git checkout tag, git pull fails in branch
Solution 1:
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.
Solution 2:
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).
Solution 3:
Try these commands:
git pull origin master
git push -u origin master
Solution 4:
Switch back to the master branch using
$ git checkout master
and then run the git pull
operation
$ git pull origin/master
Afterwards, you can switch back to your my_branch
again.
Solution 5:
@alesko : it is not possible to only do only git pull
after checkout my_branch
to update master
branch only.
Because git pull
will also merge to the current branch -> in your scenario to the my_branch
@Simon: that will do also the push. why is that?
$ git branch -u origin/master
Branch master set up to track remote branch master from origin.
and acording to docs:
-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.