git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Graphical tool to merge and reorder commits

From
RDR. Diez <rdiez-2006@rd10.de>
Date
Aug 19, 2025, 08:35 UTC
Message-ID
<aeb06554-77b5-4f07-a659-7b6825d6f3e4@rd10.de>
In-Reply-To
<aKQws631-giQS5Qr@pks.im>
Show 10 quoted lines
> I might have something related to that: I've got a patch series cooking
> that introduces a `git history` command. With this you can say:
> 
>    $ git history reorder $COMMIT_A --(before|after) $COMMIT_B
>    $ git history drop $COMMIT
>    $ git history split $COMMIT
> 
> It's only intended as a starting point, and there's additional commands
> we can eventually think about. I'll probably send an initial version of
> this series later today.
This is good news indeed, thanks for your feedback.
I guess some "git history squash" command would be useful too.
This is what frequently happens to me:
- I commit some code changes because the current project builds and tests fine.
- I start the "compile all projects" process, which takes about 1 hour.
- In the meantime, I commit other unrelated changes.
- After an hour, I realise that a silly mistake in the first commit makes compilation fail for some project.
   I fix that and I trigger a "compile all projects" again, which takes 1 hour again.
- In the meantime, I commit yet another unrelated change.
- After yet another hour, the build process notifies me that I made yet another little mistake, and yet another project fails now.
The commit history looks like this:
- A - B - fixA1 - C - fixA2 - D - E
I only do a "git push" when the 1-hour compilation process succeeds. Before the "git push", I want to reorganise that into:
- A+fixA1+fixA2 - B - C - D - E
I know I can work with branches, but branches make everything more complicated. A linear history is easier, especially when you are working alone. Besides, it is not often that I make such silly mistakes. ;-)
Sometimes, fixing something in the Git repository is so complicated that it is not worth the trouble, so I leave an "unclean" history behind. For example, sometimes I have fixed merge problems by manually overwriting the code with the final new version, losing commit history in the process, in order to avoid having to deal with Git's idiosyncrasies.
Would it be possible to provide a "safe" way to do this "git history" operations? This is what I am thinking about:
1) Start with the messed up history:
- A - B - fixA1 - C - fixA2 - D - E [head]
2) Duplicate it:
- A - B - fixA1 - C - fixA2 - D - E [head]
| A - B - fixA1 - C - fixA2 - D - E [attempt]
3) Try to clean the history of [attempt] with the new "git history reorder" etc.
4) If successful, move [head] to [attempt], and we are done.
5) If not successful, drop [attempt] and possibly leave the messed up history in [head], because the cost of fixing it would be too high.
The first duplication step is what gives me the peace of mind that, if I screw something badly, I can always drop [attempt] and go back to my original state.
I know it would be better to learn Git "properly" and do things "right", but Git is often not very user friendly, and there are other priorities in life.
Regards,
   rdiez
Previous: Patrick SteinhardtNext: Bernd Petrovitsch
Message 5 of 11 in “Graphical tool to merge and reorder commits”
  1. R. DiezAug 17, 2025
  2. Konstantin KhomoutovAug 18, 2025
  3. Junio C HamanoAug 18, 2025
  4. Patrick SteinhardtAug 19, 2025
  5. R. DiezAug 19, 2025
  6. Bernd PetrovitschAug 19, 2025
  7. Patrick SteinhardtAug 19, 2025
  8. R. DiezAug 19, 2025
  9. Ben KnobleAug 19, 2025
  10. Junio C HamanoAug 19, 2025
  11. Johannes SixtAug 19, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.