updating local master with remote master

Below worked for me like charm

  1. git checkout master
  2. git pull
  3. git checkout <your local branch>
  4. git pull --rebase --autostash origin master

Well, typically when I have an outdated master locally and want to merge recent changes in a branch (say, my_branch) to master (both locally and remotely), I do the following,

  • Checkout the master branch locally.
  • Run git pull --rebase origin master (This pulls down the most up-to-date changes on master locally)
  • Checkout local branch say my_branch
  • Run git pull --rebase origin master(This updates your local branch against the most recent master on remote. You may need to resolve the conflicts here (if any that is))
  • checkout the master branch locally, again.
  • Run git merge my_branch
  • Run git push origin master

If you have already done a git fetch upstream You can try doing while in your branch master:

 git reset --hard upstream/master

This will set your current branch to be exactly like your upstream master (it will discard any local changes btw). Check your last commit to confirm that you've got the latest in your local

Tags:

Git

Github