74 lines
4.4 KiB
Plaintext
74 lines
4.4 KiB
Plaintext
<p>Two weeks without Magit<sup id="fnref:1"><a class="footnote" href="https://www.manueluberti.eu/feed#fn:1" rel="footnote">1</a></sup> have forced me to rethink how I use Git in my
|
||
projects. I have already written about <a href="https://www.manueluberti.eu/emacs/2021/11/27/vc/">some
|
||
commands</a> I have been using,
|
||
but beside basic things, how does Emacs hold up in a more complex situation?</p>
|
||
|
||
<p>Let’s talk about interactive rebasing. If you are familiar with Magit<sup id="fnref:2"><a class="footnote" href="https://www.manueluberti.eu/feed#fn:2" rel="footnote">2</a></sup>, you
|
||
know how simple it gets. This is what I usually do from <code class="language-plaintext highlighter-rouge">magit-status</code>:</p>
|
||
|
||
<ul>
|
||
<li><kbd>l</kbd> for <code class="language-plaintext highlighter-rouge">magit-log</code></li>
|
||
<li><kbd>l</kbd> for <code class="language-plaintext highlighter-rouge">current</code></li>
|
||
<li><kbd>n</kbd> as many times as needed to move to the commit I want to start
|
||
rebasing with</li>
|
||
<li><kbd>r</kbd> for <code class="language-plaintext highlighter-rouge">magit-rebase</code></li>
|
||
<li><kbd>i</kbd> for <code class="language-plaintext highlighter-rouge">interactive</code></li>
|
||
<li><kbd>s</kbd> on the commits I want to squash</li>
|
||
<li><kbd>C-c C-c</kbd> to confirm</li>
|
||
<li>write the commit message I want</li>
|
||
<li><kbd>C-c C-c</kbd> to confirm</li>
|
||
<li><kbd>P</kbd> and <kbd>-f</kbd> to push with <code class="language-plaintext highlighter-rouge">--force-with-lease</code> enabled</li>
|
||
</ul>
|
||
|
||
<p>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.</p>
|
||
|
||
<p>Since I did not find a similar solution in <code class="language-plaintext highlighter-rouge">vc-git</code>, I asked on <code class="language-plaintext highlighter-rouge">emacs-devel</code>
|
||
how the core developers approach this workflow: <a href="https://lists.gnu.org/archive/html/emacs-devel/2021-12/msg00238.html">vc-git: interactive
|
||
rebasing</a>.
|
||
I got different, interesting replies that can be roughly summed up with:</p>
|
||
|
||
<ul>
|
||
<li>bare command line</li>
|
||
<li><code class="language-plaintext highlighter-rouge">helm-ls-git</code></li>
|
||
<li>custom code</li>
|
||
</ul>
|
||
|
||
<p>Not wanted to be scared away from a non-Magit option, this is what I
|
||
have eventually ended up doing:</p>
|
||
|
||
<ul>
|
||
<li>in <code class="language-plaintext highlighter-rouge">shell-mode</code>, I run <code class="language-plaintext highlighter-rouge">git rebase -i <branch>~<commits></code></li>
|
||
<li>in the buffer that opens up I type <code class="language-plaintext highlighter-rouge">squash</code> on the commits I want to squash</li>
|
||
<li><kbd>C-x C-s</kbd></li>
|
||
<li><kbd>C-x k RET</kbd></li>
|
||
<li>in the buffer with the commit message I edit the text as I wish</li>
|
||
<li><kbd>C-x C-s</kbd></li>
|
||
<li><kbd>C-x k RET</kbd></li>
|
||
<li>either I run <code class="language-plaintext highlighter-rouge">git push --force-with-lease</code> from <code class="language-plaintext highlighter-rouge">shell-mode</code>, or <kbd>C-u
|
||
P</kbd> from <kbd>C-x p v</kbd> to push with <code class="language-plaintext highlighter-rouge">--force-with-lease</code> added
|
||
manually</li>
|
||
</ul>
|
||
|
||
<p>Note that this approach requires that in <code class="language-plaintext highlighter-rouge">~/.config/git/config</code> I have <code class="language-plaintext highlighter-rouge">editor</code>
|
||
set to <code class="language-plaintext highlighter-rouge">emacsclient</code> and either I have <code class="language-plaintext highlighter-rouge">server-start</code> somewhere in my <code class="language-plaintext highlighter-rouge">init.el</code>
|
||
or I do <kbd>M-x server-start</kbd> before starting the actual rebase.</p>
|
||
|
||
<p>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 “<em>drop it already and party hard, fellas!</em>”. Sorry.</p>
|
||
|
||
<h3 id="notes">Notes</h3>
|
||
|
||
<div class="footnotes">
|
||
<ol>
|
||
<li id="fn:1">
|
||
<p>Not entirely true, but keep reading. <a class="reversefootnote" href="https://www.manueluberti.eu/feed#fnref:1">↩</a></p>
|
||
</li>
|
||
<li id="fn:2">
|
||
<p>Who isn’t in this day and age? <a class="reversefootnote" href="https://www.manueluberti.eu/feed#fnref:2">↩</a></p>
|
||
</li>
|
||
</ol>
|
||
</div> |