Git - How to force pull from upstream remote and ignore commit on local and remote devices?
I want to checkout from a branch upstream, and I want to ignore all commits I made on my local and remote devices on git. I only need changes from the remote pool.
I'm having problems with:
git pull upstream master
And I don't want to manually merge them. I just want to ignore all my local changes and the above command to work.
I tried:
git reset --hard
But that doesn't work for me. I want changes from upstream.
source to share
Another way to achieve this, which I have now found, is that you can remove all changes in your branch with
git checkout.
Once your branch is clean, you can checkout another branch with:
git checkout <anotherbranchname>
You can now remove the old branch locally by running:
git branch -d <branchtoremovelocalchanges>
You can now switch to that branch again:
git checkout <branchtoremovelocalchanges>
and now you will see everything as on the server. I know this is a more roundabout way of achieving what the first answer suggests, but this is a different option.
source to share