Also worth noting: you can abort and undo many kinds of in-progress operations with “git <operation> —abort”. Works for merge, rebase, and a few other things, and can seriously save your bacon when you do a “git merge <badbranch>” and are suddenly confronted with a bazillion merge conflicts.<p>Also, if you’re in a panic because something went screwy, check “git status” and read every line carefully. status tells you a lot more than you might expect - what branch you’re on, if you’re even on a branch, what merge/rebase/commit operation you’re in the middle of (if any), and even how to go forward with or back out of the current operation.<p>Finally, commit regularly and often! reflog and rebase mean that you can always maintain a clean history if you want, while committing makes sure that your changes are properly tracked and saved by git so you can rewind when needed. Once you get comfortable with it, git lets you really practice fearless experimentation, which unlocked a whole new level of productivity for me.
The thing that made git click for me was to understand the data structures that make git work.<p>There's beauty and elegance in the implementation details of git. You can do and undo with confidence once you can translate the changes you want to make to git object transformations.<p>To get an overview of the concepts behind git I recommend this article by one of the GitHub founders: <a href="http://tom.preston-werner.com/2009/05/19/the-git-parable.html" rel="nofollow">http://tom.preston-werner.com/2009/05/19/the-git-parable.htm...</a><p>To understand the data structures I suggest: <a href="https://codewords.recurse.com/issues/two/git-from-the-inside-out" rel="nofollow">https://codewords.recurse.com/issues/two/git-from-the-inside...</a>
I'm actually somewhat surprised that this wasn't mentioned in the comments yet: <a href="https://ohshitgit.com/" rel="nofollow">https://ohshitgit.com/</a> Which is a page that covers common mistakes using git and quick ways to fix your mistakes. I've found myself making a mistake mentioned on this page with regularity and always refer to the site to help myself fix it quickly.<p>(It looks like they have a swearing-safe version now at <a href="https://dangitgit.com/" rel="nofollow">https://dangitgit.com/</a>)
It has always bugged me that<p><pre><code> git commit --amend
</code></pre>
Doesn't automatically resign (or fail to resign if the key isn't available) a signed git commit message. Anytime there is a non-verified git commit message in my history you can be sure it's because I was a dummy on the original message.
This flowchart[1] has been useful to me a few times when I've been lost on how to fix something. I usually keep it as a bookmark, but I don't have it saved on this computer, so I just did a google image search and was able to fine it fairly quickly. A google image search for "git solution workflow" or "git fix flowchart" finds it right away, in case this tickles your brain in the future and you want to find it again, and vaguely remember it's easy to find through image search.<p>Edit: Updated the link to go to the site referenced in the image. Might as well send you to who developed it so they get some credit.<p>1: <a href="http://justinhileman.info/article/git-pretty/" rel="nofollow">http://justinhileman.info/article/git-pretty/</a>
Discussed at the time: <a href="https://news.ycombinator.com/item?id=9679367" rel="nofollow">https://news.ycombinator.com/item?id=9679367</a>
Except you can't undo git reset --hard unless of course you build a safety net. <a href="https://gist.github.com/chx/3a694c2a077451e3d446f85546bb9278" rel="nofollow">https://gist.github.com/chx/3a694c2a077451e3d446f85546bb9278</a>
For several months now I've been wondering how to get rid of a 700 MB data file that was accidentally committed to our shared git repo. Now everyone has it, and a clean pull takes forever. Appreciate any thoughts.
Not reading. Nothing is ever as good as this flow chart: <a href="http://sethrobertson.github.io/GitFixUm/fixup.html" rel="nofollow">http://sethrobertson.github.io/GitFixUm/fixup.html</a>
> You started a new branch feature based on master, but master was pretty far behind origin/master<p>I’m bad at git. So... wait what now?<p>When is Master not Origin/Master? I don’t understand what is going on there. Explain?