0

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

Just create a branch before squashing.

In magit:

  1. Optional: copy the name of the current branch (you can find it on the first line of the *magit* buffer).
  2. 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.)

1

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? – Gilles 'SO- stop being evil' Jan 10 at 19:44
  • It all depends on the use-case. So both answers makes sense and complete each other. – tarsius Jan 10 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.