<?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 on random thoughts</title><link>https://awesomeprogrammer.com/categories/git/</link><description>Recent content in git on random thoughts</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Tue, 18 Sep 2012 00:00:00 +0000</lastBuildDate><atom:link href="https://awesomeprogrammer.com/categories/git/index.xml" rel="self" type="application/rss+xml"/><item><title>Fixing GIT https certificate problem (insecure workaround)</title><link>https://awesomeprogrammer.com/blog/2012/09/18/fixing-git-https-certificate-problem/</link><pubDate>Tue, 18 Sep 2012 00:00:00 +0000</pubDate><guid>https://awesomeprogrammer.com/blog/2012/09/18/fixing-git-https-certificate-problem/</guid><description><![CDATA[<p>If you are using a git repository over https protocol you may encounter error:</p>
<p><code>server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://your-git-repo fatal: HTTP request failed</code></p>
<p>What it mean is that probably your hosting provider (that you are hosting your repo on) upgraded their SSL certificate (go and check it out first). Here&rsquo;s recipe for a quick fix:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>export GIT_SSL_NO_VERIFY<span style="color:#f92672">=</span><span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>git push
</span></span><span style="display:flex;"><span>git pull
</span></span><span style="display:flex;"><span>export GIT_SSL_NO_VERIFY<span style="color:#f92672">=</span><span style="color:#ae81ff">0</span>
</span></span></code></pre></div>]]></description><content:encoded><![CDATA[<p>If you are using a git repository over https protocol you may encounter error:</p>
<p><code>server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://your-git-repo fatal: HTTP request failed</code></p>
<p>What it mean is that probably your hosting provider (that you are hosting your repo on) upgraded their SSL certificate (go and check it out first). Here&rsquo;s recipe for a quick fix:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>export GIT_SSL_NO_VERIFY<span style="color:#f92672">=</span><span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>git push
</span></span><span style="display:flex;"><span>git pull
</span></span><span style="display:flex;"><span>export GIT_SSL_NO_VERIFY<span style="color:#f92672">=</span><span style="color:#ae81ff">0</span>
</span></span></code></pre></div>]]></content:encoded></item><item><title>Git deployment using post-receive hook</title><link>https://awesomeprogrammer.com/blog/2012/07/20/git-deployment-using-post-receive-hook/</link><pubDate>Fri, 20 Jul 2012 00:00:00 +0000</pubDate><guid>https://awesomeprogrammer.com/blog/2012/07/20/git-deployment-using-post-receive-hook/</guid><description><![CDATA[<p>Let&rsquo;s assume you have configured your brand new git repository on a brand new server and now you want to setup it in a way that every push done on a master branch update your production directory. How can you achieve that?</p>
<p>You can use <a href="http://git-scm.com/book/en/Customizing-Git-Git-Hooks">git hooks</a> feature. In <em>hooks/</em> directory in your git repo you can find a file called <em>post-receive</em>, take a look at quick example below:</p>
<p>{% codeblock lang:bash %}
#!/bin/bash</p>
<p>while read oldrev newrev ref
do
branch=<code>echo $ref | cut -d/ -f3</code></p>
<p>if [ &ldquo;master&rdquo; == &ldquo;$branch&rdquo; ]; then
git &ndash;work-tree=/YOUR-PRODUCTION-DIRECTORY-HERE/ checkout -f $branch
echo &lsquo;Changed pushed to production&rsquo;
fi
done
{% endcodeblock %}</p>
<p>What this script does is checking out repository to a specific directory (<em>&ndash;work-tree</em>) if this push was done on master branch. Of course you can add more stuff there, it&rsquo;s just simple example but it works great (tested with git 1.5). Unfortunately I can&rsquo;t remember where I found out about this solution, but the credit goes to the original author.</p>
<p>Also - don&rsquo;t forget to add execute permission for that file (<em>chmod +x post-receive</em>).</p>
]]></description><content:encoded><![CDATA[<p>Let&rsquo;s assume you have configured your brand new git repository on a brand new server and now you want to setup it in a way that every push done on a master branch update your production directory. How can you achieve that?</p>
<p>You can use <a href="http://git-scm.com/book/en/Customizing-Git-Git-Hooks">git hooks</a> feature. In <em>hooks/</em> directory in your git repo you can find a file called <em>post-receive</em>, take a look at quick example below:</p>
<p>{% codeblock lang:bash %}
#!/bin/bash</p>
<p>while read oldrev newrev ref
do
branch=<code>echo $ref | cut -d/ -f3</code></p>
<p>if [ &ldquo;master&rdquo; == &ldquo;$branch&rdquo; ]; then
git &ndash;work-tree=/YOUR-PRODUCTION-DIRECTORY-HERE/ checkout -f $branch
echo &lsquo;Changed pushed to production&rsquo;
fi
done
{% endcodeblock %}</p>
<p>What this script does is checking out repository to a specific directory (<em>&ndash;work-tree</em>) if this push was done on master branch. Of course you can add more stuff there, it&rsquo;s just simple example but it works great (tested with git 1.5). Unfortunately I can&rsquo;t remember where I found out about this solution, but the credit goes to the original author.</p>
<p>Also - don&rsquo;t forget to add execute permission for that file (<em>chmod +x post-receive</em>).</p>
]]></content:encoded></item></channel></rss>