Question

I want the last 4 remote commits to be reverted and go to 4 steps backward or the last 4 remote commits (done by other user) should be deleted. The red line denotes my local commit branch. Is there any way to do this? enter image description here

Was it helpful?

Solution

There are two ways, first you could keep the commits in the history but not take their changes. This will allow others who have cloned your repository to continue working without their references breaking badly. If you don’t have a good reason not to do this, this is what you should do.

You can do that my merging the “bad” commits into your master, while ignoring their changes, and keeping only yours:

git merge -s ours origin/master

If you really don’t want to keep the commits, you can also overwrite the remote’s branch by using the --force argument:

git push origin master -f

I don’t have Git Extensions installed on this machine, so I can’t tell you how to do the first option from the GUI, but you can do that by opening the Git Bash from the menu. For the force push, you can check a force checkbox somewhere in the push dialog.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top