Skip to content

Commit

Permalink
fix loom videos
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulakrishna committed Oct 31, 2023
1 parent aec5b9e commit 298ba9a
Show file tree
Hide file tree
Showing 6 changed files with 346 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
I"�<h1 id="stash-as-a-commit">Stash as a Commit</h1>

<p>Date: October 31, 2023</p>

<h3 id="what-is-a-stash">What is a Stash?</h3>

<hr />

<p>From Julia Evans’ blog article titled <strong>Some miscellaneous git facts</strong></p>

<blockquote>
<p>👉🏽 *<strong>*the stash is a bunch of commits**</strong></p>

<p>When I run <code class="language-plaintext highlighter-rouge">git stash</code> to stash my changes, I’ve always been a bit confused about where those changes actually went. It turns out that when you run <code class="language-plaintext highlighter-rouge">git stash</code>, git makes some commits with your changes and labels them with a reference called <code class="language-plaintext highlighter-rouge">stash</code> (in <code class="language-plaintext highlighter-rouge">.git/refs/stash</code>).</p>

<p>Let’s stash this blog post and look at the log of the <code class="language-plaintext highlighter-rouge">stash</code> reference:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ git log stash --oneline
6cb983fe (refs/stash) WIP on main: c6ee55ed wip
2ff2c273 index on main: c6ee55ed wip
... some more stuff

</code></pre></div> </div>

<p>Now we can look at the commit <code class="language-plaintext highlighter-rouge">2ff2c273</code> to see what it contains:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ git show 2ff2c273 --stat
commit 2ff2c273357c94a0087104f776a8dd28ee467769
Author: Julia Evans &lt;[email protected]&gt;
Date: Fri Oct 20 14:49:20 2023 -0400

index on main: c6ee55ed wip

content/post/2023-10-20-some-miscellaneous-git-facts.markdown | 40 ++++++++++++++++++++++++++++++++++++++++

</code></pre></div> </div>

<p>Unsurprisingly, it contains this blog post. Makes sense!</p>

<p><code class="language-plaintext highlighter-rouge">git stash</code> actually creates 2 separate commits: one for the index, and one for your changes that you haven’t staged yet. I found this kind of heartening because I’ve been working on a tool to snapshot and restore the state of a git repository (that I may or may not ever release) and I came up with a very similar design, so that made me feel better about my choices.</p>

<p>Apparently older commits in the stash are stored in the reflog.</p>
</blockquote>

<h3 id="why-cant-we-just-commit-instead-of-stashing">Why can’t we just commit instead of stashing?</h3>

<hr />

<p>For those used to the idea of git from command line, this may seem like a strange idea. But if your git workflow is well integrated into your IDE (I must admit, I have only VS Code in mind here), then this is such a good idea.</p>

<h4 id="the-atom-ui">The Atom UI</h4>

<p>I absolutely adored the Atom UI. The best part to me was the three pane design that put File Explorer, Code and Git in view always.</p>

<p><img src="https://thisdot.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Feb53edbf-045d-426c-aa09-d626c2816f18%2F30eb89c7-3a26-44ee-b2f2-68ee6c0aa485%2FUntitled.png?table=block&amp;id=d8d6eda7-64ee-407a-80bc-5008f3df3411&amp;spaceId=eb53edbf-045d-426c-aa09-d626c2816f18&amp;width=2000&amp;userId=&amp;cache=v2" alt="The Atom UI with File Explorer, Code Area and Git/Github Panel" /></p>

<p>The Atom UI with File Explorer, Code Area and Git/Github Panel</p>

<p>This is good because as you went making changes in files, it kept adding a list item in the right side of the screen and you had a general idea how big your changes were becoming. Putting this upfront meant a little extra motivation to go and make experimental changes anywhere which never left your view and you could just go and cherry-pick or discard everything!</p>

<p><img src="https://thisdot.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Feb53edbf-045d-426c-aa09-d626c2816f18%2Fa0cac6ea-b1a1-4188-88f2-bcd93e7ae264%2FUntitled.png?table=block&amp;id=a43d04df-ecd0-4ece-bb34-c6249ef0ace4&amp;spaceId=eb53edbf-045d-426c-aa09-d626c2816f18&amp;width=2000&amp;userId=&amp;cache=v2" alt="Atom Git Pane" /></p>

<p>Atom Git Pane</p>

<h3 id="the-flow-in-atom">The Flow in Atom</h3>

<hr />

<p>Let’s say you’re in <code class="language-plaintext highlighter-rouge">feature-branch-1</code> and you need to switch branches to <code class="language-plaintext highlighter-rouge">master</code>. Naturally, you’ll stash your changes in <code class="language-plaintext highlighter-rouge">feature-branch-1</code></p>

<p>Here’s the alternative commit method in Atom.</p>

<div style="position: relative; padding-bottom: 60.30150753768844%; height: 0;"><iframe src="https://www.loom.com/embed/1823d6c60e0646d5a8f26022267ea0cf?sid=6c6af21e-9e4d-46e5-aca9-1359e96a78b3" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe></div>

<h3 id="what-about-vs-code">What about VS Code?</h3>

<hr />

<p>VS Code doesn’t come with the same layout by default. It’s for the better and you can have the same Atom-like workflow in VS Code. Just enable a Secondary Side Bar and drag your “Source Control” and “Commits” to the second pane.</p>

<p><img src="https://thisdot.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Feb53edbf-045d-426c-aa09-d626c2816f18%2F883485c0-262f-459b-ae7c-fb679142d8ff%2FUntitled.png?table=block&amp;id=8c888b7c-77bb-4b97-89f1-3ebeb297a110&amp;spaceId=eb53edbf-045d-426c-aa09-d626c2816f18&amp;width=2000&amp;userId=&amp;cache=v2" alt="Untitled" /></p>

<p><img src="https://thisdot.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Feb53edbf-045d-426c-aa09-d626c2816f18%2F842b7ef4-deb7-4304-8063-0af1ad02e19f%2FUntitled.png?table=block&amp;id=99e468ec-9c5b-4861-9f49-0643fd5bb392&amp;spaceId=eb53edbf-045d-426c-aa09-d626c2816f18&amp;width=2000&amp;userId=&amp;cache=v2" alt="A lot more cluttered than my Atom. But it also does a lot more than Atom!" /></p>

<p>A lot more cluttered than my Atom. But it also does a lot more than Atom!</p>

<h3 id="the-same-flow-in-vs-code">The Same Flow in VS Code</h3>

<hr />

<div style="position: relative; padding-bottom: 58.91980360065466%; height: 0;"><iframe src="https://www.loom.com/embed/a1fa5c8bebd74fb889ae26dbbfcf63ee?sid=e00e01da-5fc6-4b6a-95eb-a9c3912e3e95" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe></div>

<h3 id="the-advantage">The Advantage</h3>

<hr />

<p>The real advantage is that a stash commit is local to a branch. This is ideal if you’re often working on multiple features and need to stash something to switch branches (often to master to create a new branch). So when you come back you see the stash commit and you’re back where you left it. Sometimes, when a week later when you revisit a branch, remembering that you stashed some code is not clear.</p>

<h3 id="the-case-for-stash">The case for stash</h3>

<hr />

<ul>
<li><code class="language-plaintext highlighter-rouge">git stash</code> actually frees your branch of changes for use at a later time. Which is necessary if you don’t have a branch to do a <code class="language-plaintext highlighter-rouge">stash commit</code>.</li>
<li>If you have a piece of code that you often need, but can’t commit. <code class="language-plaintext highlighter-rouge">git stash</code> is the way to go.</li>
</ul>

<h3 id="references">References</h3>

<hr />

<p>Julia Evans’ Blog Article: <a href="https://jvns.ca/blog/2023/10/20/some-miscellaneous-git-facts/">https://jvns.ca/blog/2023/10/20/some-miscellaneous-git-facts/</a></p>
:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
I"x<h1 id="stash-as-a-commit">Stash as a Commit</h1>

<p>Date: October 31, 2023</p>

<h3 id="what-is-a-stash">What is a Stash?</h3>

<hr />

<p>From Julia Evans’ blog article titled <strong>Some miscellaneous git facts</strong></p>

<blockquote>
<p>👉🏽 *<strong>*the stash is a bunch of commits**</strong></p>

<p>When I run <code class="language-plaintext highlighter-rouge">git stash</code> to stash my changes, I’ve always been a bit confused about where those changes actually went. It turns out that when you run <code class="language-plaintext highlighter-rouge">git stash</code>, git makes some commits with your changes and labels them with a reference called <code class="language-plaintext highlighter-rouge">stash</code> (in <code class="language-plaintext highlighter-rouge">.git/refs/stash</code>).</p>

<p>Let’s stash this blog post and look at the log of the <code class="language-plaintext highlighter-rouge">stash</code> reference:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ git log stash --oneline
6cb983fe (refs/stash) WIP on main: c6ee55ed wip
2ff2c273 index on main: c6ee55ed wip
... some more stuff

</code></pre></div> </div>

<p>Now we can look at the commit <code class="language-plaintext highlighter-rouge">2ff2c273</code> to see what it contains:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ git show 2ff2c273 --stat
commit 2ff2c273357c94a0087104f776a8dd28ee467769
Author: Julia Evans &lt;[email protected]&gt;
Date: Fri Oct 20 14:49:20 2023 -0400

index on main: c6ee55ed wip

content/post/2023-10-20-some-miscellaneous-git-facts.markdown | 40 ++++++++++++++++++++++++++++++++++++++++

</code></pre></div> </div>

<p>Unsurprisingly, it contains this blog post. Makes sense!</p>

<p><code class="language-plaintext highlighter-rouge">git stash</code> actually creates 2 separate commits: one for the index, and one for your changes that you haven’t staged yet. I found this kind of heartening because I’ve been working on a tool to snapshot and restore the state of a git repository (that I may or may not ever release) and I came up with a very similar design, so that made me feel better about my choices.</p>

<p>Apparently older commits in the stash are stored in the reflog.</p>
</blockquote>

<h3 id="why-cant-we-just-commit-instead-of-stashing">Why can’t we just commit instead of stashing?</h3>

<hr />

<p>For those used to the idea of git from command line, this may seem like a strange idea. But if your git workflow is well integrated into your IDE (I must admit, I have only VS Code in mind here), then this is such a good idea.</p>

<h4 id="the-atom-ui">The Atom UI</h4>

<p>I absolutely adored the Atom UI. The best part to me was the three pane design that put File Explorer, Code and Git in view always.</p>

<p><img src="https://thisdot.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Feb53edbf-045d-426c-aa09-d626c2816f18%2F30eb89c7-3a26-44ee-b2f2-68ee6c0aa485%2FUntitled.png?table=block&amp;id=d8d6eda7-64ee-407a-80bc-5008f3df3411&amp;spaceId=eb53edbf-045d-426c-aa09-d626c2816f18&amp;width=2000&amp;userId=&amp;cache=v2" alt="The Atom UI with File Explorer, Code Area and Git/Github Panel" /></p>

<p>The Atom UI with File Explorer, Code Area and Git/Github Panel</p>

<p>This is good because as you went making changes in files, it kept adding a list item in the right side of the screen and you had a general idea how big your changes were becoming. Putting this upfront meant a little extra motivation to go and make experimental changes anywhere which never left your view and you could just go and cherry-pick or discard everything!</p>

<p><img src="https://thisdot.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Feb53edbf-045d-426c-aa09-d626c2816f18%2Fa0cac6ea-b1a1-4188-88f2-bcd93e7ae264%2FUntitled.png?table=block&amp;id=a43d04df-ecd0-4ece-bb34-c6249ef0ace4&amp;spaceId=eb53edbf-045d-426c-aa09-d626c2816f18&amp;width=2000&amp;userId=&amp;cache=v2" alt="Atom Git Pane" /></p>

<p>Atom Git Pane</p>

<h3 id="the-flow-in-atom">The Flow in Atom</h3>

<hr />

<p>Let’s say you’re in <code class="language-plaintext highlighter-rouge">feature-branch-1</code> and you need to switch branches to <code class="language-plaintext highlighter-rouge">master</code>. Naturally, you’ll stash your changes in <code class="language-plaintext highlighter-rouge">feature-branch-1</code></p>

<p>Here’s the alternative commit method in Atom.</p>

<iframe src="https://www.loom.com/share/3b5ae799bb104aa5891ed51a92d5f6ca?sid=22e04793-241b-4213-aacd-a82d668dce49](https://www.loom.com/share/3b5ae799bb104aa5891ed51a92d5f6ca?sid=22e04793-241b-4213-aacd-a82d668dce49"></iframe>

<h3 id="what-about-vs-code">What about VS Code?</h3>

<hr />

<p>VS Code doesn’t come with the same layout by default. It’s for the better and you can have the same Atom-like workflow in VS Code. Just enable a Secondary Side Bar and drag your “Source Control” and “Commits” to the second pane.</p>

<p><img src="https://thisdot.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Feb53edbf-045d-426c-aa09-d626c2816f18%2F883485c0-262f-459b-ae7c-fb679142d8ff%2FUntitled.png?table=block&amp;id=8c888b7c-77bb-4b97-89f1-3ebeb297a110&amp;spaceId=eb53edbf-045d-426c-aa09-d626c2816f18&amp;width=2000&amp;userId=&amp;cache=v2" alt="Untitled" /></p>

<p><img src="https://thisdot.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Feb53edbf-045d-426c-aa09-d626c2816f18%2F842b7ef4-deb7-4304-8063-0af1ad02e19f%2FUntitled.png?table=block&amp;id=99e468ec-9c5b-4861-9f49-0643fd5bb392&amp;spaceId=eb53edbf-045d-426c-aa09-d626c2816f18&amp;width=2000&amp;userId=&amp;cache=v2" alt="A lot more cluttered than my Atom. But it also does a lot more than Atom!" /></p>

<p>A lot more cluttered than my Atom. But it also does a lot more than Atom!</p>

<h3 id="the-same-flow-in-vs-code">The Same Flow in VS Code</h3>

<hr />

<p><a href="https://www.loom.com/share/a1fa5c8bebd74fb889ae26dbbfcf63ee?sid=386b9b4e-44e3-4eec-80ab-1e5987b35dad">https://www.loom.com/share/a1fa5c8bebd74fb889ae26dbbfcf63ee?sid=386b9b4e-44e3-4eec-80ab-1e5987b35dad</a></p>

<h3 id="the-advantage">The Advantage</h3>

<hr />

<p>The real advantage is that a stash commit is local to a branch. This is ideal if you’re often working on multiple features and need to stash something to switch branches (often to master to create a new branch). So when you come back you see the stash commit and you’re back where you left it. Sometimes, when a week later when you revisit a branch, remembering that you stashed some code is not clear.</p>

<h3 id="the-case-for-stash">The case for stash</h3>

<hr />

<ul>
<li><code class="language-plaintext highlighter-rouge">git stash</code> actually frees your branch of changes for use at a later time. Which is necessary if you don’t have a branch to do a <code class="language-plaintext highlighter-rouge">stash commit</code>.</li>
<li>If you have a piece of code that you often need, but can’t commit. <code class="language-plaintext highlighter-rouge">git stash</code> is the way to go.</li>
</ul>

<h3 id="references">References</h3>

<hr />

<p>Julia Evans’ Blog Article: <a href="https://jvns.ca/blog/2023/10/20/some-miscellaneous-git-facts/">https://jvns.ca/blog/2023/10/20/some-miscellaneous-git-facts/</a></p>
:ET
Loading

0 comments on commit 298ba9a

Please sign in to comment.