<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Deployment on Lead DevOps</title><link>https://lead-devops.blackdevhub.online/en/tags/deployment/</link><description>Recent content in Deployment on Lead DevOps</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sat, 19 Sep 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://lead-devops.blackdevhub.online/en/tags/deployment/index.xml" rel="self" type="application/rss+xml"/><item><title>Deploying with a post-receive Git Hook</title><link>https://lead-devops.blackdevhub.online/en/posts/git-hook-post-receive-dlya-deploya/</link><pubDate>Sat, 19 Sep 2026 00:00:00 +0000</pubDate><guid>https://lead-devops.blackdevhub.online/en/posts/git-hook-post-receive-dlya-deploya/</guid><description>&lt;p&gt;Deploying through CI is great, but sometimes you just need to push code to a server with a single &lt;code&gt;git push&lt;/code&gt;. The &lt;code&gt;post-receive&lt;/code&gt; hook in a bare repository handles this without extra dependencies: push to the server, and the hook automatically checks out files into the working directory.&lt;/p&gt;&#10;&lt;h2 id="schema-bare-repo-as-a-deploy-trigger"&gt;Schema: bare repo as a deploy trigger&#10;&lt;/h2&gt;&#10;&lt;p&gt;The logic is straightforward:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;A bare repository is created on the server (e.g., &lt;code&gt;/srv/deploy/app.git&lt;/code&gt;).&lt;/li&gt;&#10;&lt;li&gt;The developer adds it as a remote and runs &lt;code&gt;git push origin main&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;Git receives the data and triggers &lt;code&gt;hooks/post-receive&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;The hook script runs &lt;code&gt;git --work-tree=/var/www/app --git-dir=/srv/deploy/app.git checkout -f main&lt;/code&gt;.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="td-callout td-callout--note" role="note"&gt;&#10; &lt;div class="td-callout__title"&gt;&lt;i class="td-callout__icon fa-solid fa-circle-info" aria-hidden="true"&gt;&lt;/i&gt;&lt;span class="td-callout__label"&gt;Note&lt;/span&gt;&lt;/div&gt;&#10; &lt;div class="td-callout__body"&gt;&#10;&lt;p&gt;A bare repository has no working directory. That is why &lt;code&gt;post-receive&lt;/code&gt; must explicitly pass &lt;code&gt;--work-tree&lt;/code&gt; so &lt;code&gt;checkout&lt;/code&gt; knows where to write files.&lt;/p&gt;</description></item></channel></rss>