Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

updating local master with remote master

Tags:

git

github

I have a branch that I want to merge to the remote, most up-to-date master. I have a local, outdated master on my computer. I ran git pull upstream master, and it retrieved the remote master, and that was great, exactly what I wanted. Then, without thinking, i accidentally discarded the changes while switching to another branch.

While on my local master, I have run git pull, and git pull upstream master many times now, and it always says "Already up to date." when it clearly isn't. At first git pull upstream master worked just fine, but now it doesn't, and the machine thinks it is up to date when it isn't. How can I make my local master the same as the remote one again?

like image 763
jjjjjjjj Avatar asked Apr 11 '16 05:04

jjjjjjjj


1 Answers

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
like image 103
Som Bhattacharyya Avatar answered Oct 14 '22 15:10

Som Bhattacharyya