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:
lformagit-loglforcurrentnas many times as needed to move to the commit I want to start rebasing withrformagit-rebaseiforinteractiveson the commits I want to squashC-c C-cto confirm- write the commit message I want
C-c C-cto confirmPand-fto push with--force-with-leaseenabled
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 rungit rebase -i <branch>~<commits> - in the buffer that opens up I type
son the commits I want to squash C-x C-sC-x k RET- in the buffer with the commit message I edit the text as I wish
C-x C-sC-x k RET- either I run
git push --force-with-leasefromshell-mode, orC-u PfromC-x p vto push with--force-with-leaseadded 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.