Two weeks without Magit1 have forced me to rethink how I use Git in my projects. I have already written about some commands I have been using, but beside basic things, how does Emacs hold up in a more complex situation?

Let’s talk about interactive rebasing. If you are familiar with Magit,2 you know how simple it gets. This is what I usually do from magit-status:

  • l for magit-log
  • l for current
  • n as many times as needed to move to the commit I want to start rebasing with
  • r for magit-rebase
  • i for interactive
  • s on the commits I want to squash
  • C-c C-c to confirm
  • write the commit message I want
  • C-c C-c to confirm
  • P and -f to push with --force-with-lease enabled

It’s quicker to do it than to write it all down, especially now that it has become muscle memory. No wonder I was still relying on Magit to interactively rebase on my first days with VC.

Since I did not find a similar solution in vc-git, I asked on emacs-devel how the core developers approach this workflow. I got different, interesting replies that can be roughly summed up with:

  • bare command line
  • helm-ls-git
  • custom code

Not wanting to be scared away from a non-Magit option, this is what I have eventually ended up doing:

  • in shell-mode, I run git rebase -i <branch>~<commits>
  • in the buffer that opens up I type s on the commits I want to squash
  • C-x C-s
  • C-x k RET
  • in the buffer with the commit message I edit the text as I wish
  • C-x C-s
  • C-x k RET
  • either I run git push --force-with-lease from shell-mode, or C-u P from C-x p v to push with --force-with-lease added manually

Note that this approach requires that in ~/.config/git/config I have editor set to emacsclient and either I have server-start somewhere in my init.el or I do M-x server-start before starting the actual rebasing.

It looks like that even without Magit I can do everything from Emacs, which makes for a good alternative in my opinion. Nonetheless, it does not take a PhD to notice that Magit makes the whole rebasing easier to sort out. Hence, you will not hear me scream “drop it already and party hard, fellas!”. Sorry.


  1. Not entirely true, but keep reading. ↩︎

  2. Who isn’t in this day and age? ↩︎