tamakisquare
tamakisquare

Reputation: 17077

Forgot to use `--squash` and now the commit history is a mess. How can I clean up this mess?

I was supposed to perform subtree pull --squash for a third-party module that my project depends on, but I accidentally forgot to put --squash. Now my project commit history is flooded with the third-party module commits. They are scattered all over the log.

This mess needs to be gone. How would I identify all the commits that belongs to the third-party module, squash them into one, and then purge them from my project history, if possible at all?

More info:

Note that I have done several commits, that I intend to keep, after the broken operation.

Upvotes: 5

Views: 3211

Answers (1)

Carl Norum
Carl Norum

Reputation: 225072

  1. Use git reflog to find your project's state from before you did the broken operation.
  2. Check out that hash or git reset --hard to it.
  3. Redo the operation with the correct flags.

Upvotes: 7

Related Questions