emacs/var/elfeed/db/data/a4/a475481144039793c0881dad90fb7264c4b665e6
2022-01-03 12:49:32 -06:00

76 lines
4.7 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>Lets 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>Its 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<sup id="fnref:3"><a class="footnote" href="https://www.manueluberti.eu/feed#fn:3" rel="footnote">3</a></sup>. 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 &lt;branch&gt;~&lt;commits&gt;</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 isnt in this day and age? <a class="reversefootnote" href="https://www.manueluberti.eu/feed#fnref:2">↩</a></p>
</li>
<li id="fn:3">
<p><a href="https://lists.gnu.org/archive/html/emacs-devel/2021-12/msg00238.html" target="_blank">vc-git: interactive rebasing</a>. <a class="reversefootnote" href="https://www.manueluberti.eu/feed#fnref:3">↩</a></p>
</li>
</ol>
</div>