Magit is a Git porcelain (an interface, as opposed to “plumbing”) for Emacs. Also see my git notes or /emacs page. Super useful interface. I’ve actually donated to Jonas Bernoulli and got a Magit sticker, which I still need to put somewhere.
Links
- Homepage
- https://magit.vc/
- Source
- https://github.com/magit/magit
- Manual
- https://magit.vc/manual/
Cheatsheet
- M-x magit-log-buffer-file
- Show a log of commits touching the current file.
- Pushing
- P (e.g. P p)
- Pulling
- F (e.g. F u to fetch from upstream)
Fixups
Type c F to do an instant fixup (which modifies another commit.
I accidentally did c f which just adds a commit with fixup!
prepended in the title.
If you do this, use r f to rebase autosquash.
Undo a committed hunk
Use case: I accidentally deleted a large chunk of text in a commit, and wanted to bring it back.
To reverse the changes of a committed hunk (like when viewing a log with M-x magit-log-buffer-file), select a region/hunk with an active region/transient mark, then press v which does “magit-reverse
”.
You can then stage these changes as normal (in magit-status
select the hunk again and press s).
Then use the fixup commands (documented earlier) to apply changes back to the offending commit.
Seems like you should be able to do many of these steps in one go, but I haven’t looked up how.
To-dos
Or other questions I have.
-
How do I display log dates in absolute and not relative date format?
Answer: Customize the variable
magit-log-margin
(documented in the Magit manual). Mine’s currently set to(t "%Y-%m-%d %H:%M " magit-log-margin-width t 18)
.