I have the following message in git:
# Your branch and 'origin/master' have diverged, # and have 3 and 8 different commits each, respectively. # (use "git pull" to merge the remote branch into yours)
I would like to throw away the 3 local commits, and pull the 8 remote commits at origin/master.
(Merging is going to be too difficult, I'd rather make the 3 local commits again once master is up to date.)
How can I do this?
If your excess commits are only visible to you, you can just do git reset --hard origin/<branch_name> to move back to where the origin is. This will reset the state of the repository to the previous commit, and it will discard all local changes.
Follow. Occasionally, you or your team members may run into a diverged branch. A diverged branch means the data you're looking at locally isn't the same as what is currently stored on our servers.
git fetch origin git reset --hard origin/master
To preserve your old commits on a temporary branch in case you need them:
git branch temp
Then switch to the new master
git fetch origin git reset --hard origin/master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With