0

I coded a time-limited feature that has been merged to master and shipped to production. Now that the time is up, I'd like to remove the commits containing the feature from the code base.

Ordinarily I would do a git rebase -i and delete the commits.

However, these commits have already been pushed to the remote repository, so when I rebase locally and try to push the branch I get complaints about how the tip of my branch is behind, and can be fast-forwarded.

Is there a way to generate a "new commit" from a rebase, to undo the commits I don't want? I don't really care about having a "clean" commit history, any way to back out those commits would be great.

Kevin Burke
  • 61,194
  • 76
  • 188
  • 305

2 Answers2

1

You have to git push --force your branch to any remote, since by default, push refuses to rewrite history.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
0

If you just want to get rid of the functionality (but not the history of the functionality) and it is all contained within a few specific commits (that don't affect other functionality) then git revert could be your answer.

This isn't always a nicely usable option (for example the commits might include other functionality that you don't want removed), or you may have some compelling reason to want any trace of the functionality removed, but it's a handy command to be aware of.

Cebjyre
  • 6,552
  • 3
  • 32
  • 57