<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel><title>git | Hugo Ferreira</title>
    <link>https://hugo.ferreira.cc/tags/git/</link>
    <description>Recent content in Git by Hugo Ferreira</description>
    <image>
      <title>git | Hugo Ferreira</title>
      <url>https://hugo.ferreira.cc/hf-bw.jpg</url>
      <link>https://hugo.ferreira.cc/tags/git/</link>
    </image>
    <generator>Hugo -- 0.124.1</generator>
    <language>en</language>
    <copyright>2000–2024 by Hugo Ferreira · CC BY 4.0</copyright>
    <lastBuildDate>Mon, 12 Oct 2020 01:03:51 +0000</lastBuildDate>
    <atom:link href="https://hugo.ferreira.cc/tags/git/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>✂️ Git</title>
      <link>https://hugo.ferreira.cc/git/</link>
      <pubDate>Mon, 12 Oct 2020 01:03:51 +0000</pubDate>
      <guid>https://hugo.ferreira.cc/git/</guid>
      <description>Small information nuggets and recipies about Git</description>
      <content:encoded><![CDATA[<p>See also:</p>
<blockquote>
<p>So here are some bad situations I&rsquo;ve gotten myself into, and how I eventually got myself out of them <em>in plain english</em>.</p>
<p>— <a href="https://ohshitgit.com">Oh Shit, Git!?!</a></p>
</blockquote>
<hr>
<p><em>(most recent on top)</em></p>
<h2 id="search-for-commits-that-add-or-delete-a-string-pickaxe">Search for commits that add or delete a string (pickaxe)</h2>
<ul>
<li><a href="http://www.philandstuff.com/2014/02/09/git-pickaxe.html">The git pickaxe</a>
<ul>
<li>via <a href="https://springernature.slack.com/archives/C0R5SM347/p1711371850137259">Roman Seidelsohn</a></li>
<li>via <a href="https://springernature.slack.com/archives/C0R5SM347/p1711374365573009?thread_ts=1711371850.137259&amp;channel=C0R5SM347&amp;message_ts=1711374365.573009">Jim Kinsey</a></li>
</ul>
</li>
</ul>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">git log -p -S example
</span></span></code></pre></div><pre tabindex="0"><code>-p
  Generate patch text

-S&lt;string&gt;
  Look for differences that change the number of occurrences of the specified
  string (i.e. addition/deletion) in a file.

-G&lt;regex&gt;
  Look for differences whose patch text contains added/removed lines that match &lt;regex&gt;.
</code></pre><h2 id="configure-separate-git-users-for-different-repos">Configure separate Git users for different repos</h2>
<ul>
<li>via <a href="https://app.slack.com/team/UMGKV4QKH">Aleksander Sumowski</a></li>
</ul>
<p><em>… <code>~/.gitconfig</code></em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-properties" data-lang="properties"><span class="line"><span class="cl"><span class="err">[user]</span>
</span></span><span class="line"><span class="cl">  <span class="na">name</span> <span class="o">=</span> <span class="s">First Last</span>
</span></span><span class="line"><span class="cl">  <span class="na">email</span> <span class="o">=</span> <span class="s">personal@example.org</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="na">[includeIf</span> <span class="s">&#34;gitdir:~/work/&#34;]</span>
</span></span><span class="line"><span class="cl">  <span class="na">path</span> <span class="o">=</span> <span class="s">~/work/.gitconfig</span>
</span></span></code></pre></div><p><em>… <code>~/work/.gitconfig</code></em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-properties" data-lang="properties"><span class="line"><span class="cl"><span class="err">[user]</span>
</span></span><span class="line"><span class="cl">  <span class="na">email</span> <span class="o">=</span> <span class="s">work@example.com</span>
</span></span></code></pre></div><h2 id="revert-changes-of-a-single-file-of-a-commit">Revert changes of a single file of a commit</h2>
<ul>
<li>via <a href="https://ios.slack.com/archives/C6DSYLCGZ/p1568122893055200">Michael Brown</a></li>
</ul>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git show &lt;commit&gt; -- some_file.c <span class="p">|</span> git apply -R
</span></span></code></pre></div><h2 id="manually-ignore-changes-to-a-tracked-file-or-directory">Manually ignore changes to a tracked file or directory</h2>
<ul>
<li><a href="https://wildlyinaccurate.com/git-ignore-changes-in-already-tracked-files/">Git: Ignore changes to already-tracked files | Wildly Inaccurate</a></li>
</ul>
<p><em>… stop tracking</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git update-index --assume-unchanged &lt;file&gt;
</span></span></code></pre></div><p><em>… resume tracking</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git update-index --no-assume-unchanged &lt;file&gt;
</span></span></code></pre></div><h2 id="rebase-a-topic-branch-into-anywhere-you-want">Rebase a topic branch into anywhere you want</h2>
<ul>
<li><a href="https://stackoverflow.com/questions/134882/undoing-a-git-rebase/137363#137363">Undoing a git rebase - Stack Overflow</a></li>
</ul>
<p><em>… <code>topic</code> info <code>master</code> (run from any branch)</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git rebase master topic                     <span class="c1"># default is HEAD of master</span>
</span></span><span class="line"><span class="cl">git rebase master topic --onto commit
</span></span></code></pre></div><h2 id="change-the-committer-and-author-names">Change the committer and author names</h2>
<ul>
<li><a href="https://stackoverflow.com/questions/750172/how-to-change-the-author-and-committer-name-and-e-mail-of-multiple-commits-in-gi/1320317#1320317">version control - How to change the author and committer name and e-mail of multiple commits in Git? - Stack Overflow</a></li>
</ul>
<p><em>… set default repo user</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git config user.name <span class="s2">&#34;User Name&#34;</span>
</span></span><span class="line"><span class="cl">git config user.email user@example.com
</span></span></code></pre></div><p><em>… author = <strong>default</strong>, committer = <strong>default</strong></em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git commit --amend --no-edit --reset-author
</span></span></code></pre></div><p><em>… author = <strong>custom</strong>, committer = <strong>default</strong></em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git commit --amend --no-edit --author <span class="s2">&#34;Author Name &lt;author@example.com&gt;&#34;</span>
</span></span></code></pre></div><p><em>… author = same, committer = <strong>custom</strong></em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git -c user.name<span class="o">=</span><span class="s2">&#34;Committer Name&#34;</span> -c user.email<span class="o">=</span>committer@example.com commit --amend --no-edit
</span></span></code></pre></div><p><em>… in many commits</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git rebase -i -p
</span></span><span class="line"><span class="cl"><span class="c1"># mark as: edit</span>
</span></span><span class="line"><span class="cl"><span class="c1"># repeat as above</span>
</span></span></code></pre></div><h2 id="fixup-commits-and-autosquash-rebases">Fixup commits and autosquash rebases</h2>
<ul>
<li><a href="https://robots.thoughtbot.com/autosquashing-git-commits">Auto-squashing Git Commits</a></li>
</ul>
<p><em>… create</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># squash fixed commit; prefixes message with &#34;squash! &#34;</span>
</span></span><span class="line"><span class="cl">git commit --squash e37dc68
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># fixup relative commit; prefixes message with &#34;fixup! &#34;</span>
</span></span><span class="line"><span class="cl">git commit --fixup @~1
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># fixup commit with string; prefixes message with &#34;fixup! &#34;</span>
</span></span><span class="line"><span class="cl">git commit --fixup :/foobar
</span></span></code></pre></div><p><em>… apply</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># auto reorganises the squash/fixup and moves them to the right place</span>
</span></span><span class="line"><span class="cl">git rebase -i --autosquash
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># makes it the default for all rebases</span>
</span></span><span class="line"><span class="cl">git config --global rebase.autosquash <span class="nb">true</span>
</span></span></code></pre></div><h2 id="find-broken-commit">Find broken commit</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git bisect start &lt;bad&gt; &lt;good&gt;
</span></span></code></pre></div><p><em>… example</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git bisect start @ origin/master
</span></span><span class="line"><span class="cl">git bisect run bin/test.sh
</span></span></code></pre></div><h2 id="detect-which-folders-are-affected-by-the-latest-commits-monorepo">Detect which folders are affected by the latest commits (monorepo)</h2>
<ul>
<li>via <a href="https://github.com/EqualExperts/ee-budget-app/blob/master/Jenkinsfile#L12">Equal Experts</a></li>
</ul>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git diff-tree --no-commit-id --name-only HEAD tag
</span></span></code></pre></div><h2 id="delete-remote-branch-or-tag">Delete remote branch or tag</h2>
<ul>
<li><a href="http://stackoverflow.com/a/2003515/1380781">How to delete a Git branch both locally and remotely? - Stack Overflow</a></li>
</ul>
<p><em>… as of v1.7</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git push origin --delete &lt;branch_name&gt;
</span></span><span class="line"><span class="cl">git push origin --delete &lt;tag_name&gt;
</span></span></code></pre></div><p><em>… before that</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git push origin :&lt;branch_name&gt;
</span></span></code></pre></div><h2 id="differences-between-local-and-upstream">Differences between local and upstream</h2>
<ul>
<li>via <a href="https://twitter.com/ajh_17/status/673000158573944832">Akshay on Twitter: &ldquo;@tpope It was released around git v2.0 I think. It’s been nice to use: git diff @..@{u} to diff the local and the upstream branches.&rdquo;</a></li>
</ul>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git diff @<span class="o">{</span>u<span class="o">}</span>..@
</span></span></code></pre></div><h2 id="the--sign-is-an-alias-for-head">The <code>@</code> sign is an alias for <code>HEAD</code></h2>
<ul>
<li><a href="https://twitter.com/tpope/status/671724545125040128">Tim Pope on Twitter: &ldquo;whoa nice, @ is an alias for HEAD in git now git show @^&rdquo;</a></li>
</ul>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git show @
</span></span><span class="line"><span class="cl">git show @~2
</span></span></code></pre></div><h2 id="change-a-commit-original-author-date">Change a commit original author date</h2>
<ul>
<li><a href="https://stackoverflow.com/questions/454734/how-can-one-change-the-timestamp-of-an-old-commit-in-git">How can one change the timestamp of an old commit in Git? - Stack Overflow</a></li>
<li><a href="https://stackoverflow.com/questions/9110310/update-git-commit-author-date-when-amending">Update git commit author date when amending - Stack Overflow</a></li>
</ul>
<p><em>… set author date</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git commit --amend --no-edit --date<span class="o">=</span><span class="s2">&#34;Sun Dec 31 12:34:56 2017&#34;</span>
</span></span></code></pre></div><p><em>… set committer date + author date</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nv">GIT_COMMITTER_DATE</span><span class="o">=</span><span class="s2">&#34;Sun Dec 31 23:45:00 2017&#34;</span> git commit --amend --no-edit --date<span class="o">=</span><span class="s2">&#34;Sun Dec 31 23:45:00 2017&#34;</span>
</span></span></code></pre></div><p><em>… set committer date = author date</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nv">GIT_COMMITTER_DATE</span><span class="o">=</span><span class="s2">&#34;Mon May 7 23:54:</span><span class="k">$(</span><span class="nb">echo</span> <span class="k">$((</span>RANDOM <span class="o">%</span> <span class="m">50</span> <span class="o">+</span> <span class="m">10</span><span class="k">))</span> <span class="p">|</span> cut -c-2<span class="k">)</span><span class="s2"> 2018&#34;</span> bash -c <span class="s1">&#39;git commit --amend --no-edit --date=&#34;$GIT_COMMITTER_DATE&#34;&#39;</span>
</span></span></code></pre></div><p><em>… random seconds</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">echo</span> <span class="k">$((</span>RANDOM <span class="o">%</span> <span class="m">50</span> <span class="o">+</span> <span class="m">10</span><span class="k">))</span> <span class="p">|</span> cut -c-2
</span></span></code></pre></div><p><em>… see also custom function shell <a href="https://github.com/hugocf/dotfiles/blob/a64f9b1/bash/bash_aliases#L55-L64"><code>git-commit-dates()</code></a></em></p>
<h2 id="rebase-commits-to-reset-commit-date-to-the-original-author-date">Rebase commits to reset commit date to the original author date</h2>
<ul>
<li><a href="http://stackoverflow.com/questions/2973996/git-rebase-without-changing-commit-timestamps/2976598#2976598">git rebase without changing commit timestamps - Stack Overflow</a></li>
</ul>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git rebase --committer-date-is-author-date @~3
</span></span></code></pre></div><h2 id="auto-stash-dirty-directory-on-pullrebase">Auto stash dirty directory on pull/rebase</h2>
<ul>
<li>via <a href="https://equalexperts.slack.com/archives/today-i-learned/p1466446425000002">Anil Wadghule</a></li>
</ul>
<p><em>… autostash is only available since git version 2.9</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git pull --rebase --autostash
</span></span></code></pre></div><p><em>… for earlier versions use:</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git config --global rebase.autoStash <span class="nb">true</span>
</span></span></code></pre></div><h2 id="check-lightweight-vs-annotated-tags">Check lightweight vs. annotated tags</h2>
<ul>
<li><a href="http://git-scm.com/book/en/v2/Git-Basics-Tagging#Annotated-Tags">Git - Tagging#Annotated Tags</a></li>
</ul>
<p><em>… <strong>annotated</strong>: “You can see the tag data along with the commit that was tagged by using the</em> <em>git show</em> <em>command”</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ git show annotated-tag
</span></span><span class="line"><span class="cl">tag annotated-tag
</span></span><span class="line"><span class="cl">Tagger: Hugo Ferreira &lt;hugo@ferreira.cc&gt;
</span></span><span class="line"><span class="cl">Date:   Thu Dec <span class="m">24</span> 10:54:15 <span class="m">2015</span> +0000
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">message text with details
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">commit 6ec10ad250c8bbbdc42dba51a09c02b456e02187 <span class="o">(</span>tag: annotated-tag<span class="o">)</span>
</span></span><span class="line"><span class="cl">Author: Hugo Ferreira &lt;hugo.ferreira@digital.hmrc.gov.uk&gt;
</span></span><span class="line"><span class="cl">Date:   Thu Dec <span class="m">24</span> 10:23:50 <span class="m">2015</span> +0000
</span></span></code></pre></div><p><em>… <strong>lightweight</strong>: “This time, if you run</em> <em>git show</em> <em>on the tag, you don’t see the extra tag information. The command just shows the commit”</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ git show light-tag
</span></span><span class="line"><span class="cl">commit f5d32c57c9612c610dc0c45cc0ff3f0b1d21fd53 <span class="o">(</span>HEAD -&gt; master, tag: light-tag<span class="o">)</span>
</span></span><span class="line"><span class="cl">Author: Hugo Ferreira &lt;hugo@ferreira.cc&gt;
</span></span><span class="line"><span class="cl">Date:   Thu Dec <span class="m">24</span> 10:25:44 <span class="m">2015</span> +000
</span></span></code></pre></div><h2 id="set-user--email-info">Set user &amp; email info</h2>
<p><em>… current repo only <code>.git/config</code></em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git config user.name <span class="s2">&#34;Hugo Ferreira&#34;</span>
</span></span><span class="line"><span class="cl">git config user.email hugo.ferreira@example.com
</span></span></code></pre></div><p><em>… default for all repos <code>~/.gitconfig</code></em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git config --global user.name <span class="s2">&#34;Hugo Ferreira&#34;</span>
</span></span><span class="line"><span class="cl">git config --global user.email hugo.ferreira@example.com
</span></span></code></pre></div><h2 id="prepare-a-patch-formatted-for-email">Prepare a patch formatted for email</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git format-patch HEAD~1
</span></span><span class="line"><span class="cl">git format-patch &lt;sha&gt;..@
</span></span></code></pre></div><h2 id="apply-a-patch-received-as-file">Apply a patch received as file</h2>
<p><em>… dry-run</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git apply --check --stat 0001-file.patch
</span></span></code></pre></div><p><em>… apply and create commits</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git am 0001-file.patch
</span></span></code></pre></div><p><em>… apply patch to files</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># files only</span>
</span></span><span class="line"><span class="cl">git apply 0001-file.patch
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># files + index</span>
</span></span><span class="line"><span class="cl">git apply --index 0001-file.patch
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># index only</span>
</span></span><span class="line"><span class="cl">git apply --cached 0001-file.patch
</span></span></code></pre></div><h2 id="show-files-being-ignored">Show files being ignored</h2>
<ul>
<li><a href="http://stackoverflow.com/a/467053/1380781">Show ignored files in git - Stack Overflow</a></li>
</ul>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git clean --dry-run -dX
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git clean -ndX
</span></span></code></pre></div><h2 id="choose-a-new-root-commit-for-the-repo">Choose a new root commit for the repo</h2>
<ul>
<li><a href="http://stackoverflow.com/questions/2246208/change-first-commit-of-project-with-git/14629246#14629246">git rebase - Change first commit of project with Git? - Stack Overflow</a></li>
</ul>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git rebase -i --root
</span></span></code></pre></div><h2 id="visualise-the-entire-commit-graph">Visualise the entire commit graph</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git log --graph --oneline --all --color --decorate
</span></span></code></pre></div><h2 id="rollback-the-last-commit-for-good">Rollback the last commit for good</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git reset HEAD~1 --hard
</span></span></code></pre></div><h2 id="undo-a-rebase">Undo a rebase</h2>
<ul>
<li><a href="https://stackoverflow.com/questions/41049711/git-how-to-rollback-a-rebase/41049867#41049867">Git how to rollback a rebase - Stack Overflow</a></li>
</ul>
<p><em>… show the history of operations (like an “undo” stack)</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ git reflog
</span></span><span class="line"><span class="cl">b710729 HEAD@<span class="o">{</span>0<span class="o">}</span>: rebase: some commit
</span></span><span class="line"><span class="cl">5ad7c1c HEAD@<span class="o">{</span>1<span class="o">}</span>: rebase: another commit
</span></span><span class="line"><span class="cl">deafcbf HEAD@<span class="o">{</span>2<span class="o">}</span>: checkout: moving from master to my-branch
</span></span></code></pre></div><p><em>… reset to the commit before the rebase</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git reset --hard deafcbf
</span></span></code></pre></div><h2 id="recover-lost-commits">Recover lost commits</h2>
<ul>
<li><a href="http://gitready.com/advanced/2009/01/17/restoring-lost-commits.html">git ready » restoring lost commits</a></li>
</ul>
<p><em>… discover</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git fsck --lost-found
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git reflog
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git show &lt;sha1&gt;
</span></span></code></pre></div><p><em>… restore</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git cherry-pick &lt;sha1&gt;
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git merge &lt;sha1&gt;
</span></span></code></pre></div><h2 id="show-outgoing-changes">Show outgoing changes</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git fetch <span class="o">&amp;&amp;</span> git whatchanged origin..
</span></span></code></pre></div><h2 id="show-incoming-changes">Show incoming changes</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git fetch <span class="o">&amp;&amp;</span> git whatchanged ..origin
</span></span></code></pre></div><h2 id="git-flow-rules-of-engagement-for-releases-merge-commit-messages"><code>git-flow</code> rules of engagement for releases (merge commit) messages</h2>
<p><em>… setup</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git config --global merge.log <span class="nb">true</span>
</span></span></code></pre></div><p><em>… default message</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">Merge branch <span class="s1">&#39;release/1.0.0&#39;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">* develop:
</span></span><span class="line"><span class="cl">  One commit message
</span></span><span class="line"><span class="cl">  Another commit message
</span></span></code></pre></div><p><em>… edit: commit message (merge)</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">Merge branch <span class="s1">&#39;release/1.0.0&#39;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">- One commit message
</span></span><span class="line"><span class="cl">- Another commit message
</span></span></code></pre></div><p><em>… edit: tag message (releases)</em></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">release/1.0.0
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">- One commit message
</span></span><span class="line"><span class="cl">- Another commit message
</span></span></code></pre></div>]]></content:encoded>
    </item>
    <item>
      <title>🔗 GitHub Flow -- Scott Chacon</title>
      <link>https://hugo.ferreira.cc/github-flow-scott-chacon/</link>
      <pubDate>Thu, 29 Aug 2013 07:07:28 +0000</pubDate>
      <guid>https://hugo.ferreira.cc/github-flow-scott-chacon/</guid>
      <description>GitHub Flow &amp;ndash; Scott Chacon
So, what is GitHub Flow?
Anything in the master branch is deployable To work on something new, create a descriptively named branch off of master (ie: new-oauth2-scopes ) Commit to that branch locally and regularly push your work to the same named branch on the server When you need feedback or help, or you think the branch is ready for merging, open a pull request After someone else has reviewed and signed off on the feature, you can merge it into master Once it is merged and pushed to &amp;lsquo;master&amp;rsquo;, you can and should deploy immediately For teams that have to do formal releases on a longer term interval (a few weeks to a few months between releases), and be able to do hot-fixes and maintenance branches and other things that arise from shipping so infrequently, git-flow makes sense and I would highly advocate it&amp;rsquo;s use.</description>
      <content:encoded><![CDATA[<p><a href="http://scottchacon.com/2011/08/31/github-flow.html">GitHub Flow &ndash; Scott
Chacon</a></p>
<blockquote>
<p>So, what is GitHub Flow?</p>
<ul>
<li>Anything in the master branch is deployable</li>
<li>To work on something new, create a descriptively named branch off
of master (ie: <code>new-oauth2-scopes</code> )</li>
<li>Commit to that branch locally and regularly push your work to the
same named branch on the server</li>
<li>When you need feedback or help, or you think the branch is ready
for merging, open a <a href="http://help.github.com/send-pull-requests/">pull
request</a></li>
<li>After someone else has reviewed and signed off on the feature, you
can merge it into master</li>
<li>Once it is merged and pushed to &lsquo;master&rsquo;, you can and <em>should</em>
deploy immediately</li>
</ul>
</blockquote>
<blockquote>
<p>For teams that have to do formal releases on a longer term interval (a
few weeks to a few months between releases), and be able to do
hot-fixes and maintenance branches and other things that arise from
shipping so infrequently,
<a href="http://nvie.com/posts/a-successful-git-branching-model/">git-flow</a>
makes sense and I would highly advocate it&rsquo;s use.</p>
<p>For teams that have set up a culture of shipping, who push to
production every day, who are constantly testing and deploying, I
would advocate picking something simpler like GitHub Flow.</p>
</blockquote>
]]></content:encoded>
    </item>
    <item>
      <title>🔗 Install and manage WordPress with Git</title>
      <link>https://hugo.ferreira.cc/install-and-manage-wordpress-with-git/</link>
      <pubDate>Tue, 24 Jul 2012 07:07:28 +0000</pubDate>
      <guid>https://hugo.ferreira.cc/install-and-manage-wordpress-with-git/</guid>
      <description>Install and manage WordPress with Git
Manage themes and plugins in a git repository, while at the same time keep a reference to the core WordPress files, and allow it to be as easy to update when a new version is released.</description>
      <content:encoded><![CDATA[<p><a href="http://davidwinter.me/articles/2012/04/09/install-and-manage-wordpress-with-git/">Install and manage WordPress with
Git</a></p>
<blockquote>
<p>Manage themes and plugins in a git repository, while at the same time
keep a reference to the core WordPress files, and allow it to be as
easy to update when a new version is released.</p>
</blockquote>
]]></content:encoded>
    </item>
  </channel>
</rss>
