0

Here's the situation as presented by Git Extensions:

enter image description here

A and B were pushed to origin/master. Then another developer merged C. It turns out that C is better on its own. A, B, and the merged HEAD should be blown away, and C should become the new HEAD.

I saw a Q&A about how to roll back remote. My doubt is about the terminology. Is a rollback what I want to do here? If not, what would this operation be called?

I am currently the only developer working on this project, so I don't have to worry about disrupting anyone else's work.

StackOverthrow
  • 1,158
  • 11
  • 23

1 Answers1

0

When you're the only developer, you can use the easy way out which is normally not suggested, that is, you reset your local branch to whatever commit you need, with git reset --hard <commit-sha1> and then you do a git push --force, forcefully overwriting the remote.

The cleaner way would still be to just discard the two commits, A and B, by reverting them. git revert <A-sha1> and git revert <B-sha1> will get rid of the changes introduced by those two commits, while leaving them in history. Then you would be able to push as usual.

To address terminology specifically, there's nothing called a rollback in Git. When people talk about rolling back in the context of Git, they usually mean either revert or reset. To put those two simply, revert undoes a commit by creating a new commit that undoes the changes. And reset makes a branch point at a different commit in history, potentially resulting in commits being lost entirely.

DUman
  • 2,560
  • 13
  • 16