2

I was committing a large file to git, and it appears my editor messed up somehow when editing the commit message file. The result is the entire diff of ~100k lines became my "commit message". This is now slowing down the entire git server every time I load a page in the repository.

I know that I can simply run the interactive rebase on my master branch to edit the commit message.

Unfortunately, by the time I realized that this, the offending commit had already been merged into the master branch, and from there into several other branches as well. So does that mean I have to track down the commit in every single branch and repeat the rebase on it?

I recall that in git, commits are immutable objects while branches are simply labels on commits. So it's not that "multiple branches have a commit", but a single commit can be a member of several branches. Does this mean that if I edit the commit on master branch only, the other branches will also be fixed? Or is that not the case because the interactive rebase simply creates a new commit with my edited message, as opposed to literally editing the original commit object?

Wassinger
  • 347
  • 2
  • 16

1 Answers1

1

If you want to edit your history, the common point to all solutions is :

  • you will have to force push the result,
  • you will have to tell everyone to take the necessary steps to move their work to the new history, so that they do not upload the old history the next time they push to the central repo.

To rewrite that specific commit for all branches, look into git filter-repo or git filter-branch rather than git rebase.

LeGEC
  • 46,477
  • 5
  • 57
  • 104