In the recent Git, you can add -r
/--rebase
on pull
command to rebase your current branch on top of the upstream branch after fetching. The warning should disappear, but there is a risk that you'll get some conflicts which you'll need to solve.
Alternatively you can checkout different branch with force, then go back to master
again, e.g.:
git checkout origin/master -f
git checkout master -f
Then pull it again as usual:
git pull origin master
Using this method can save you time from stashing (git stash
) and potential permission issues, reseting files (git reset HEAD --hard
), removing files (git clean -fd
), etc. Also the above it's easier to remember.