<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="367386" data-post-id="367386">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mwilding" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mwilding
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I have other more advanced ones, but really once you get too complex, it is better to just have reference.  I always forget them if the get too complex.</p>
<pre data-code-wrap="sh"><code class="lang-sh">

alias ga='git add'
alias gb='git branch'
alias gc='git checkout'
alias gcb='git checkout -b'
alias gca='git commit --amend'
alias gcme='git commit -m '
alias gd='git diff'
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367386" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/helpful-git-aliases-and-config-settings/71267/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-367386" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367386"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="367387" data-post-id="367387">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="adamu" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/adamu/120/31482_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  adamu
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="jswanner" data-post="10" data-topic="71267">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jswanner/48/24585_2.png" class="avatar"> jswanner:</div>
<blockquote>
<p>Does shell completion work with these functions?</p>
</blockquote>
</aside>
<p>From <code>.bash_profile</code>:</p>
<pre data-code-wrap="bash"><code class="lang-bash">source ~/.git-completion.bash
__git_complete g __git_main # Makes git completion work with 'g' alias
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367387" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/helpful-git-aliases-and-config-settings/71267/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-367387" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367387"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="367389" data-post-id="367389">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jswanner" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jswanner/120/24585_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jswanner
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Ah nice, not having working shell completion is what bothered me the last time I tried having functions like these.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367389" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/helpful-git-aliases-and-config-settings/71267/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-367389" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367389"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="367403" data-post-id="367403">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sodapopcan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/120/34668_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sodapopcan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Ya, forgetting them is the main reason I don’t like a lot of aliases.  Holding a bunch of acronyms in my head is hard for me.  I also don’t like forgetting how to do the actual thing (if possible).</p>
<p><em>Another</em> reason I just realized because it’s so ingrained, which is also a reason I never thought about bash completion (beyond file names), is that I use <a href="https://github.com/zsh-users/zsh-autosuggestions" rel="noopener nofollow ugc">zsh-autosuggest</a> which gives fish-style completions which I love.  Couple that with <a href="https://github.com/zsh-users/zsh-syntax-highlighting" rel="noopener nofollow ugc">zsh-syntax-highlighting</a> for the full effect!  With the latter you don’t even really need <code>which</code>/<code>command -v</code> anymore—if a command is green, you’re good!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367403" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/helpful-git-aliases-and-config-settings/71267/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-367403" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367403"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="367435" data-post-id="367435">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jswanner" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jswanner/120/24585_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jswanner
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sodapopcan" data-post="15" data-topic="71267">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/48/34668_2.png" class="avatar"> sodapopcan:</div>
<blockquote>
<p>Ya, forgetting them is the main reason I don’t like a lot of aliases. Holding a bunch of acronyms in my head is hard for me. I also don’t like forgetting how to do the actual thing (if possible).</p>
</blockquote>
</aside>
<p>This is something I <em>really</em> like about fish abbreviations: they expand from the abbreviated form to their full form either on <code>&lt;enter&gt;</code> (to run as is) or on <code>&lt;space&gt;</code> (to adjust the command before running).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367435" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/helpful-git-aliases-and-config-settings/71267/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-367435" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367435"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="367440" data-post-id="367440">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="regex.sh" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/regex.sh/120/17382_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  regex.sh
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I use this one, it comes with <code>ohmyzsh git</code> I think <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p>
<pre data-code-wrap="bash"><code class="lang-bash">❯ alias gcssm
gcssm='git commit --gpg-sign --signoff --message'
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367440" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/helpful-git-aliases-and-config-settings/71267/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-367440" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367440"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="367457" data-post-id="367457">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="christhekeele" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/christhekeele/120/1039_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  christhekeele
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I have quite a few aliases and config recommendations. My personal favorite is <code>git oops</code>.</p>
<h2><a name="p-367457-tip-patch-mode-1" class="anchor" href="#p-367457-tip-patch-mode-1" aria-label="Heading link" rel="nofollow"></a>Tip: Patch Mode</h2>
<p>Neither config nor alias per-se, but very useful: I do almost all my staging of changes hunk-by-hunk rather than file-by-file with <code>git add -p</code> (<code>--patch</code>). Check it out if you’ve never used it before! It allows me to craft much more intentional commits from a messy work tree.</p>
<p>It especially makes it really easy to do things like add temporary imports/requires/aliases for debugging purposes, and log/debug statements, in your code without accidentally committing them, or having to unwind them for committing purposes.</p>
<p>There are quite a few options when adding in “patch” mode, <code>?</code> will give you some context. Over time I’ve incorporated <code>y,n,q,a,d,j</code> pretty deep into my muscle memory and workflow, but it takes some time and just <code>y/n/q</code> is a good start. For the purpose of subdividing hunks in order to separate a debug log line from some relevant code you want to commit, use <code>s</code>.</p>
<p>Already use <code>git add -p</code>? Did you know that <code>--patch</code> also works with:</p>
<ul>
<li><code>git reset</code> to selectively un-stage changes from files in the index into the work tree</li>
<li><code>git restore</code> to selectively discard changes from files in the work tree</li>
<li><code>git stash</code> to selectively stash changes from files out of the work tree</li>
</ul>
<h2><a name="p-367457-config-2" class="anchor" href="#p-367457-config-2" aria-label="Heading link" rel="nofollow"></a>Config</h2>
<p>A lot of my config is fairly specific to my own preferred git workflows, but these are workflow-agonistic, useful for anyone, and in my opinion should be defaults.</p>
<ul>
<li>
<p><code>rerere.enabled = true</code></p>
<p><strong>Re</strong>use <strong>Re</strong>corded <strong>Re</strong>solution. Better ink than mine has been spilled on this, but essentially, if you ever rebase at all, you want this set. It makes dealing with merge conflicts while rebasing palatable.</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global rerere.enabled true
</code></pre>
</li>
<li>
<p><code>merge.conflictstyle = diff3</code></p>
<p>Adds a third section to merge conflicts, showing what the code looked like before either conflicting commit touched it. This gives essential context to what each author was trying to accomplish when changing the code, making it much more trivial to reconcile.</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global merge.conflictstyle diff3
</code></pre>
</li>
<li>
<p><code>diff.mnemonicprefix = true</code></p>
<p><a href="https://git-scm.com/docs/git-diff#Documentation/git-diff.txt-codediffmnemonicPrefixcode" rel="noopener nofollow ugc">Uses helpful prefixes</a> rather than the default <code>a/file/name</code> and <code>b/file/name</code> when diffing between things, where at least one thing is not a commit. Makes it easier to remember halfway scrolling through a long diff if you are comparing between a commit (<code>c/</code>), the index (<code>i/</code>), or the work tree (<code>w/</code>); or comparing two arbitrary commits (back to <code>a/</code> and <code>b/</code>).</p>
<p>Useful if you often run <code>git diff</code> with various arguments (<code>git diff</code>, <code>git diff &lt;ref&gt;</code>, <code>git diff --cached</code>).</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global diff.mnemonicprefix true
</code></pre>
</li>
</ul>
<h2><a name="p-367457-aliases-3" class="anchor" href="#p-367457-aliases-3" aria-label="Heading link" rel="nofollow"></a>Aliases</h2>
<p>I also don’t care for the git alphabet soup shortcuts many folk use, it makes it harder for rich tab-completion and command history tools to work. I type just fast enough that using the full form doesn’t really slow down common operations, and think just slowly enough it wouldn’t speed up uncommon ones. I also tend to make <em>more</em> typos mashing out a short vowel-less alias and jamming <kbd>Enter</kbd> than I would composing a full command using things closer to full words.</p>
<h3><a name="p-367457-utility-4" class="anchor" href="#p-367457-utility-4" aria-label="Heading link" rel="nofollow"></a>Utility</h3>
<ul>
<li>
<p><code>git alias</code></p>
<p>An alias that lists all aliases.</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global alias.alias "!alias(){ git config --get-regexp '^alias.${1}'; }; alias"
</code></pre>
</li>
<li>
<p><code>git cherrypick</code></p>
<p>Because I forget the <code>-</code> in <code>cherry-pick</code>, every time.</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global alias.cherrypick cherry-pick
</code></pre>
</li>
</ul>
<h3><a name="p-367457-informational-5" class="anchor" href="#p-367457-informational-5" aria-label="Heading link" rel="nofollow"></a>Informational</h3>
<ul>
<li>
<p><code>git current</code></p>
<p>Shows the current local branch.</p>
<p>Useful for scripting purposes, prompt display, or command substitution.</p>
<p>For example, when pushing up a branch for the first time, <code>git push -u origin $(git current)</code>.</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global alias.current rev-parse --abbrev-ref HEAD
</code></pre>
</li>
<li>
<p><code>git last</code></p>
<p>Shows a rich display of the last commit.</p>
<p>Customizable using <a href="https://git-scm.com/docs/git-log#_pretty_formats" rel="noopener nofollow ugc">pretty formats</a>.</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global alias.last "log -n1 --pretty='format:Commit: %C(yellow)%H%nAuthored by: %C(magenta)%aN %Creset%ar%nCommited by: %Cblue%cN %Creset%cr%n%n%B'"

</code></pre>
</li>
<li>
<p><code>git latest [N]</code></p>
<p>Shows a rich summary of the last <code>N</code> commits, default <code>5</code>.</p>
<p>Customizable using <a href="https://git-scm.com/docs/git-log#_pretty_formats" rel="noopener nofollow ugc">pretty formats</a>.</p>
<p>(I use <code>--- &gt;8 ---</code> to separate commits because I also <a href="https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---cleanupmode" rel="noopener nofollow ugc">use <code>commit.cleanup = scissors</code></a> and it pleases me.)</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global alias.latest "log -n${1:-5} --pretty='format:%Cgreen---------------------- &gt;8 ----------------------%nCommit: %C(yellow)%H%nAuthored by: %C(magenta)%aN %Creset%ar%nCommited by: %Cblue%cN %Creset%cr%n%n%s%n'"
</code></pre>
</li>
<li>
<p><code>git contains &lt;ref&gt;</code></p>
<p>Lists the branches a <code>&lt;ref&gt;</code> is in.</p>
<p>Performs a <code>fetch</code> first to ensure you are up-to-date with, ex, PRs being merged into mainline while working on your branch.</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global alias.contains "!contains(){ git fetch &amp;&amp; git rev-parse ${1:-HEAD} | xargs git branch -r --contains; }; contains"
</code></pre>
</li>
<li>
<p><code>git ancestor &lt;branch1&gt; [&lt;branch2&gt;]</code></p>
<p>Shows the last commit shared between two branches. Uses <code>HEAD</code> if only one branch is provided.</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global alias.ancestor merge-base --octopus
</code></pre>
</li>
</ul>
<h3><a name="p-367457-history-modification-6" class="anchor" href="#p-367457-history-modification-6" aria-label="Heading link" rel="nofollow"></a>History Modification</h3>
<ul>
<li>
<p><code>git oops [-m "new message"] [-a | list/of/files]</code></p>
<p>Add something you forgot to the latest commit.</p>
<p>Any staged changes in the index are folded into the last commit you made. Other unstaged changes in the work tree can be added by listing files, or all unstaged changes can be added with <code>-a</code>.</p>
<p>The commit’s message can be changed with <code>-m</code>, but unlike standard commiting, you will not be presented with an editor if none is provided: the existing message will be left as-is.</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global alias.oops commit --amend --no-edit
</code></pre>
</li>
<li>
<p><code>git rollback [N]</code></p>
<p>Soft-resets the latest <code>N</code> commits, default <code>1</code>.</p>
<p>All changes in rolled back commits are preserved, staged into the index.</p>
<pre data-code-wrap="sh"><code class="lang-sh">git config set --global alias.rollback "!rollback(){ cd ${GIT_PREFIX:-.} &amp;&amp; git reset HEAD~${1:-1} --soft; }; rollback"
</code></pre>
</li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367457" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/helpful-git-aliases-and-config-settings/71267/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-367457" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367457"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-most-liked cat-most-liked" title="One of the top 3 liked posts in this thread!"></div>
  </section>
</div>
    <div class="postbit" id="367458" data-post-id="367458">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sodapopcan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/120/34668_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sodapopcan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><code>add -p</code> is one of those things you think couldn’t possibly be usable as you think you need more context but turns out it’s really intuitive.  The vast majority of folks at an old job used it.</p>
<p>All of these are great but, well, I’ll sound like a broken record but I just do most of this stuff in fugutive.vim.</p>
<p>That’s interesting you prefer soft reset—I did that for years and removed the <code>--soft</code> after realizing I was essentially always doing <code>git reset --soft head^ &amp;&amp; git reset</code> (although not exactly like that) which is of course just <code>git reset head^</code>.  Is there are part of your workflow that you’d rather keep them staged?  I’m guessing it’s about getting <em>new</em> diff markers for new changes after reset?</p>
<p>I’ve had <code>rerere</code> set for years and I don’t think I ever knew what it did <img src="https://forum.elixirforum.com/images/emoji/apple/sweat_smile.png?v=15" title=":sweat_smile:" class="emoji" alt=":sweat_smile:" loading="lazy" width="20" height="20"></p>
<p>+1 for <code>git oops</code> <img src="https://forum.elixirforum.com/images/emoji/apple/grin.png?v=15" title=":grin:" class="emoji" alt=":grin:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367458" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/helpful-git-aliases-and-config-settings/71267/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-367458" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367458"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="367459" data-post-id="367459">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="christhekeele" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/christhekeele/120/1039_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  christhekeele
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sodapopcan" data-post="19" data-topic="71267">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/48/34668_2.png" class="avatar"> sodapopcan:</div>
<blockquote>
<p>That’s interesting you prefer soft reset—I did that for years and removed the <code>--soft</code> after realizing I was essentially always doing <code>git reset --soft head^ &amp;&amp; git reset</code> (although not exactly like that) which is of course just <code>git reset head^</code>. Is there are part of your workflow that you’d rather keep them staged? I’m guessing it’s about getting <em>new</em> diff markers for new changes after reset?</p>
</blockquote>
</aside>
<p>Yup, pretty much.</p>
<p>I have another alias (<code>git undo</code>) for unwinding commits that is the same as <code>rollback N</code>, using the default (<code>--mixed</code>) reset mode. I also have a <code>git erase</code> for <code>--hard</code> resets. With my workflow, I tend to find myself using <code>rollback</code> the most often by far, so that’s the one I share.</p>
<p>The main reason why I want to ‘unwind’ one or more (usually fairly intentionally crafted) commits is because I have ongoing work that leads me to discover that previous work was partially incorrect or incomplete. A <code>--soft</code> reset helps me partition a) the work previously committed (into the index) from b) the work I was doing in the work tree that led me to discover that I want to unwind some commits. Othertimes, I’ll unwind commits because they were intentionally temporary and exploratory, in which case I’m preparing to finalize some of their contents into an intentionally crafted commit, so placing them into the index ready to commit saves me a step.</p>
<p>Then I’ll usually use <code>add/reset/restore/stash --patch</code> modes to “rebuild” the previously committed work in the index into a proper committable state: shifting hunks between the old commits, my dirty worktree of discovery, the stash for things I might want to come back to, and nonexistence.</p>
<p>Often only <em>some</em> of the contents of my dirty worktree need to take part in this dance when I start it; so <code>--mixed</code> would muddle what I was unwinding with what I’ve discovered whereas <code>--soft</code> leaves them partitioned.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367459" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/helpful-git-aliases-and-config-settings/71267/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-367459" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367459"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #19"></div>
  </section>
</div>
    <div class="postbit" id="367463" data-post-id="367463">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sodapopcan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/120/34668_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sodapopcan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m going to need to think on this more (really try it out) but that’s interesting.  My general workflow is to just keep committing then rebase (using calling commits <code>"squish with &lt;some words from the commit to squash with&gt;"</code>) but I do sometimes find myself in messes I don’t bother to totally fix and this could help.  Again, though, gotta think on it and actually try it out.  My resets are otherwise always to break up the last commit and add/edit and recommit altogether or as 2 or 3 new ones.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367463" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/helpful-git-aliases-and-config-settings/71267/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-367463" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367463"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/71267/load_more?page=3">Load more posts (2 remaining)</a>
</div></template></turbo-stream>