From: "R. Diez" <rdiez-2006@rd10.de>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: Graphical tool to merge and reorder commits
Date: Tue, 19 Aug 2025 10:35:38 +0200 [thread overview]
Message-ID: <aeb06554-77b5-4f07-a659-7b6825d6f3e4@rd10.de> (raw)
In-Reply-To: <aKQws631-giQS5Qr@pks.im>
> 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
next prev parent reply other threads:[~2025-08-19 8:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-17 21:02 Graphical tool to merge and reorder commits R. Diez
2025-08-18 18:04 ` Konstantin Khomoutov
2025-08-18 18:34 ` Junio C Hamano
2025-08-19 8:07 ` Patrick Steinhardt
2025-08-19 8:35 ` R. Diez [this message]
2025-08-19 9:51 ` Bernd Petrovitsch
2025-08-19 11:05 ` Patrick Steinhardt
2025-08-19 11:14 ` R. Diez
2025-08-19 12:08 ` Ben Knoble
2025-08-19 16:33 ` Junio C Hamano
2025-08-19 19:09 ` Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aeb06554-77b5-4f07-a659-7b6825d6f3e4@rd10.de \
--to=rdiez-2006@rd10.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.