More Productive Git
If you really want more productive Git, stop playing the Git Adventure Game!<p>When you poke at your repo on the command line, you never get to see it as a unified whole. All you can do is try a command, see what it prints out, and try to make a mental model of what this all means.<p>A good Git GUI will <i>show</i> you the state of your repo and unify all of the scattered concepts of the command line like the index, the reflog, and stashes.<p>SmartGit is my favorite. I&#x27;ve also heard good things about Tower, although it&#x27;s only available on Mac and Windows, not Linux. (SmartGit supports all three.)<p>A couple of examples from the article:<p>&gt; <i>The process of a cherry-pick is brief. First, we identify the SHA for the commit or commits you want to pick, using git log or the like. Next, we check out the branch we want to apply the commit(s) to. We then pick the commits.</i><p><pre><code>  git cherry-pick d8119f49cd4fd6b0366c5ca3af205f9c25af89ba
</code></pre>
In SmartGit, you see the commit you want to pick in the log, right click it, and select Cherry-Pick.<p>&gt; <i>Another common issue is committing and then discovering you missed something in that commit. Sure, you could make an edit and add another commit, but sometimes you want to maintain all related changes in a single commit. In this case, you can use the git commit --amend command to fix it up.</i><p>&gt; <i>Let’s say you’ve edited useful_func.clj and then committed it.</i><p><pre><code>  git add useful_func.clj
  git commit -m &quot;Added even more useful function&quot;
</code></pre>
&gt; <i>But you forgot to commit your code and document your new function. Instead of editing and committing again, you can amend. Make the required changes to the useful_func.clj file, then add it again:</i><p><pre><code>  git add useful_func.clj
</code></pre>
&gt; <i>But instead of running a normal commit, run an amendment.</i><p><pre><code>  git commit --amend --no-edit
</code></pre>
&gt; <i>This will amend your last commit with your new changes and commit it. The --no-edit flag tells Git not to launch the editor and skip amending the commit log message. If you want to update the commit log message too, you can omit this flag.</i><p>In SmartGit, you use the same Commit dialog as a normal commit. It&#x27;s on the menu, or Ctrl+K (Command+K on Mac) will take you right there. The Commit dialog has an &quot;Amend last commit&quot; checkbox which is normally unchecked. Simply check that box and it will do an amended commit. You can either keep the previous commit message that is displayed in the dialog, or edit it right there.<p>A couple of other topics the article doesn&#x27;t touch on...<p>What about the index? In SmartGit, you can either use the index or ignore it as you see fit. I rarely use it myself. The Commit dialog just does the right thing when I ignore the index, committing my working tree changes directly. And if I do want to use the index, it&#x27;s easy to get to from the same dialogs.<p>One of my favorite features in SmartGit is how it handles the reflog. Instead of printing out a list of hashes and poking through them to find the one you need, simply click the Recyclable Commits box in the log view. Now every commit in the reflog shows up as part of the normal commit log tree. You can work with these commits just like any other.<p>It does the same thing with stashes. Click the Stashes checkbox and they show up in the commit log too. (I wonder how many Git users realize that a stash is simply another commit by a different name?)<p>Maybe you&#x27;re not sure exactly what was changed between two fairly distant commits? Click one of them, and then Ctrl+click the other. Now the Files panel shows you exactly which files were changed between these two commits and the exact differences.<p>I could go on for a while, but what I really wonder is why so many developers are reluctant to even <i>try</i> a Git GUI like SmartGit. It is so much more powerful and productive than the command line adventure game.