79436409

Date: 2025-02-13 14:02:48
Score: 1
Natty:
Report link

Oh well, poor OT.

On the surface, this looks like a simple scenario. But in version control, for this type of impulses, there are no simple scenarios.

Start with thinking about what you really want:

With that out of the way, the OP asked specifically for the commits to be gone, even though I'd ask back: are you sure? Are you really sure?

And then it gets complicated. What do mean by 'commits be gone'? git rebase -i gives you options and not everything is what you think it is:

  1. A commit is a visible step in the version history
  2. A commit is a captured and frozen change of any number of files managed in the git repository. If you really are only interested in the visible history of commits, you do not want to use 'git rebase -i' to 'drop' or delete a line, but rather use 'squash' to make it look like it never happened. If you really are sure that all the lines you added in any file have that unmistakable smell of doom to them, then you might think the right thing to do is to delete or 'drop' the commits. Just be aware that the real pain is not over, but it starts here.

A) Dropping a commit will then lead to conflicts with subsequent commits where git tries to apply them. That is the very nature of version control, i.e. the frozen change of state of any number of files. Applying a commit where it doesn't fit will not work in many cases and the more changes, the more conflicts.

B) Did any of the responses mention branches? All your branches will still be there, with all their history. 'git rebase -i' lets you make changes to one branch (e.g. main), but will not affect your branches and branch points. Which is good, as otherwise you couldn't play with the commits that you branched from. But it is bad if you were trying to conceal the commits. They are all still there in the branches!!!

C) Are you working collaboratively with anyone? Are you aware of git push/pull? This is at the heart of git. And what you are suggesting is pulling the rug out from under your buddies feet. They are sure to want to return that favor.

Good luck.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Martin F Schulz