summaryrefslogtreecommitdiff
path: root/.html/git/survival.html
diff options
context:
space:
mode:
Diffstat (limited to '.html/git/survival.html')
-rw-r--r--.html/git/survival.html174
1 files changed, 174 insertions, 0 deletions
diff --git a/.html/git/survival.html b/.html/git/survival.html
new file mode 100644
index 0000000..c1d43ac
--- /dev/null
+++ b/.html/git/survival.html
@@ -0,0 +1,174 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>
+ The Codex »
+ Git Survival Guide
+ </title>
+
+ <link
+ rel='stylesheet'
+ type='text/css'
+ href='http://fonts.googleapis.com/css?family=Buenard:400,700&amp;subset=latin,latin-ext'>
+ <link
+ rel="stylesheet"
+ type="text/css"
+ href="../media/css/reset.css">
+ <link
+ rel="stylesheet"
+ type="text/css"
+ href="../media/css/grimoire.css">
+</head>
+<body>
+
+<div id="shell">
+
+ <ol id="breadcrumbs">
+
+ <li class="crumb-0 not-last">
+
+ <a href="../">index</a>
+
+ </li>
+
+ <li class="crumb-1 not-last">
+
+ <a href="./">git</a>
+
+ </li>
+
+ <li class="crumb-2 last">
+
+ survival
+
+ </li>
+
+ </ol>
+
+
+
+ <div id="article">
+ <h1 id="git-survival-guide">Git Survival Guide</h1>
+<p>I think the <code>git</code> UI is pretty awful, and encourages using Git in ways that
+will screw you. Here are a few things I've picked up that have saved my bacon.</p>
+<ul>
+<li>You will inevitably need to understand Git's “internals” to make use of it
+ as an SCM tool. Accept this early. If you think your SCM tool should not
+ expose you to so much plumbing, <a href="http://mercurial.selenic.com">don't</a>
+ <a href="http://bazaar.canonical.com">use</a> <a href="http://subversion.apache.org">Git</a>.<ul>
+<li>Git weenies will claim that this plumbing is what gives Git all of its
+ extra power. This is true; it gives Git the power to get you out of
+ situations you wouldn't be in without Git.</li>
+</ul>
+</li>
+<li><code>git log --graph --decorate --oneline --color --all</code></li>
+<li>Run <code>git fetch</code> habitually. Stale remote-tracking branches lead to sadness.</li>
+<li><code>git push</code> and <code>git pull</code> are <strong>not symmetric</strong>. <code>git push</code>'s
+ opposite operation is <code>git fetch</code>. (<code>git pull</code> is equivalent to <code>git fetch</code>
+ followed by <code>git merge</code>, more or less).</li>
+<li><a href="config">Git configuration values don't always have the best defaults</a>.</li>
+<li>The upstream branch of <code>foo</code> is <code>foo@{u}</code>. The upstream branch of your
+ checked-out branch is <code>HEAD@{u}</code> or <code>@{u}</code>. This is documented in <code>git help
+ revisions</code>.</li>
+<li>You probably don't want to use a merge operation (such as <code>git pull</code>) to
+ integrate upstream changes into topic branches. The resulting history can be
+ very confusing to follow, especially if you integrate upstream changes
+ frequently.<ul>
+<li>You can leave topic branches “real” relatively safely. You can do
+ a test merge to see if they still work cleanly post-integration without
+ actually integrating upstream into the branch permanently.</li>
+<li>You can use <code>git rebase</code> or <code>git pull --rebase</code> to transplant your
+ branch to a new, more recent starting point that includes the changes
+ you want to integrate. This makes the upstream changes a permanent part
+ of your branch, just like <code>git merge</code> or <code>git pull</code> would, but generates
+ an easier-to-follow history. Conflict resolution will happen as normal.</li>
+</ul>
+</li>
+<li>
+<p>Example test merge, using <code>origin/master</code> as the upstream branch and <code>foo</code>
+ as the candidate for integration:</p>
+<pre><code>git fetch origin
+git checkout origin/master -b test-merge-foo
+git merge foo
+# run tests, examine files
+git diff origin/master..HEAD
+</code></pre>
+<p>To discard the test merge, delete the branch after checking out some other
+branch:</p>
+<pre><code>git checkout foo
+git branch -D test-merge-foo
+</code></pre>
+<p>You can combine this with <code>git rerere</code> to save time resolving conflicts in
+a later “real,” permanent merge.</p>
+</li>
+<li>
+<p>You can use <code>git checkout -p</code> to build new, tidy commits out of a branch
+ laden with “wip” commits:</p>
+<pre><code>git fetch
+git checkout $(git merge-base origin/master foo) -b foo-cleaner-history
+git checkout -p foo -- paths/to/files
+# pick out changes from the presented patch that form a coherent commit
+# repeat 'git checkout -p foo --' steps for related files to build up
+# the new commit
+git commit
+# repeat 'git checkout -p foo --' and 'git commit' steps until no diffs remain
+</code></pre>
+<ul>
+<li>Gotcha: <code>git checkout -p</code> will do nothing for files that are being
+ created. Use <code>git checkout</code>, instead, and edit the file if necessary.
+ Thanks, Git.</li>
+<li>Gotcha: The new, clean branch must diverge from its upstream branch
+ (<code>origin/master</code>, in the example above) at exactly the same point, or
+ the diffs presented by <code>git checkout -p foo</code> will include chunks that
+ revert changes on the upstream branch since the “dirty” branch was
+ created. The easiest way to find this point is with <code>git merge-base</code>.</li>
+</ul>
+</li>
+</ul>
+<h2 id="useful-resources">Useful Resources</h2>
+<p>That is, resoures that can help you solve problems or understand things, not
+resources that reiterate the man pages for you.</p>
+<ul>
+<li>Sitaram Chamarty's <a href="http://sitaramc.github.com/gcs/">git concepts
+ simplified</a></li>
+<li>Tv's <a href="http://eagain.net/articles/git-for-computer-scientists">Git for Computer
+ Scientists</a></li>
+</ul>
+ </div>
+
+
+
+<div id="comments">
+<div id="disqus_thread"></div>
+<script type="text/javascript">
+ /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
+ var disqus_shortname = 'grimoire'; // required: replace example with your forum shortname
+
+ /* * * DON'T EDIT BELOW THIS LINE * * */
+ (function() {
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
+ dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
+ })();
+</script>
+<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
+<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
+</div>
+
+
+
+ <div id="footer">
+ <p>
+
+ The Codex —
+
+ Powered by <a href="http://markdoc.org/">Markdoc</a>.
+
+<a href="https://bitbucket.org/ojacobson/grimoire.ca/src/master/wiki/git/survival.md">See this page on Bitbucket</a> (<a href="https://bitbucket.org/ojacobson/grimoire.ca/history-node/master/wiki/git/survival.md">history</a>).
+
+ </p>
+ </div>
+
+</div>
+</body>
+</html> \ No newline at end of file