1

One programmer has erroneously pushed his commits to devel branch instead of his own branch. Then he made his own branch and continued to work in it correctly. But develop branch appeared to be "contaminated" with wrong unapproved commits.

How to rollback this?

Dims
  • 47,675
  • 117
  • 331
  • 600
  • Maybe `git checkout dev;` `git reset --hard HEAD^`? – Emadpres Nov 05 '18 at 09:58
  • But how will this fix remote? – Dims Nov 05 '18 at 10:00
  • Reset local as @Emadpres described, then `git push --force` to the remote. This will overwrite the remote develop with your local one, which has been reset. – kowsky Nov 05 '18 at 10:08
  • Force push after resetting the `dev` branch to the correct commit (be aware of the implications...). Otherwise, revert the commits (and deal with the mess later on when merging his branch back to `dev`). – alfunx Nov 05 '18 at 10:08
  • Possible duplicate of [How can I remove a commit on GitHub?](https://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github) – phd Nov 05 '18 at 12:27
  • https://stackoverflow.com/search?q=%5Bgit%5D+remove+commits – phd Nov 05 '18 at 12:28

1 Answers1

1

First fix the local side as:

git checkout dev
git reset --hard HEAD^

Then push this update to the remote with --force as:

git push --force
Emadpres
  • 3,466
  • 2
  • 29
  • 44