0

I want to undo all changes on remote repository so that it represents the state as it was after commit id bd5bf14, how can I achieve this?

This is my current graph:

* 299b710 (HEAD -> master, origin-prod/master) Separation of objects 
* 2c3a084  bifurcation
*   bd5bf14 Merge branch 'master' of https://gitlab.********
|\
| * 63b5065 changed downtime 
| * dba5e46 added module
| * 9f52520 added module for Infra
| * 287e409 added module for Infra
| * 7e38cdf added module for Infra
* | be1dd06 Separation of objects
|/
* 934feb2 downtime added.
*   f41b8a6 Merge branch 'master' of https://gitlab.*********
|\
| * dc09c13 Update environment
* | 12ca95d Several changes.
|/
Matt
  • 12,848
  • 2
  • 31
  • 53
Maven
  • 14,587
  • 42
  • 113
  • 174
  • 1
    Does this answer your question? [How do I revert a Git repository to a previous commit?](https://stackoverflow.com/questions/4114095/how-do-i-revert-a-git-repository-to-a-previous-commit) – Wing Jun 05 '21 at 14:56

1 Answers1

1

If you want to go back to bd5bf14 on the remote only, you can force-push like this:

git push -f origin-prod bd5bf14:master

If you want to go back locally and on the remote, you can hard-reset to the desired state and then force-push:

git reset --hard bd5bf14
git push -f origin-prod master

Be aware that this removes the commits from the remote branch and might have an impact on other developers. A safe way to undo the changes is to revert them which generates a commit without rewriting history:

git revert --no-commit bd5bf14..HEAD
git commit
git push origin-prod master
Matt
  • 12,848
  • 2
  • 31
  • 53