1

We have some commit on git which was wrongly added We have done some more commits also above that wrong commit. Now I want to remove that commit without affecting on other commits.

Is there any way to remove it?

Please guide

Curious_k.shree
  • 990
  • 2
  • 18
  • 37

2 Answers2

3

remove that commit without affecting on other commits

Use git revert: that will create a new commit which will cancel the ones you don't want to see. You will be able to push that new commit.
You can revert a range of commits.

But that means the data from those "wrong comimts" remains in the history.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

You can revert any commit, regardless of where it is in your history. Just type git revert <sha>.

You may have to do a conflict resolution if there are conflicts.

Matt Parlane
  • 453
  • 2
  • 11