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
  • 970
  • 2
  • 16
  • 36

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,129,465
  • 480
  • 4,036
  • 4,755
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
  • 443
  • 2
  • 10