Does magit offer a way to squash a bunch of commits, but preserve some sort of record of the micro commits - should you need to step through them the next day.
2 Answers
Just create a branch before squashing.
In magit:
- Optional: copy the name of the current branch (you can find it on the first line of the
*magit*
buffer). b n
to create a new branch. Paste the name of the current branch if it helps you, and give the new branch a unique name (e.g. with a-detailed-history
suffix).
(But better yet, don't squash. A detailed commit history is useful and squashing rarely has any benefit.)
Magit does not provide any feature specifically for this use-case. It does however expose a git
feature that can be used in this and other situations when you have to recover some discarded work: the reflog.
The reflog commands are available from the same popup menu as the log commands: l.
Search the web for information about what the reflog is and how to use it.
While viewing a reflog you can use l o RET to view the log for the reflog entry at point.
-
The reflog won't be preserved for long and can't be pushed. Why not give the current commit history a persistent name, i.e. a branch? Jan 10, 2021 at 19:44
-
It all depends on the use-case. So both answers makes sense and complete each other.– tarsiusJan 10, 2021 at 20:54