<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Git on Chris Titus Tech | Tech Content Creator</title><link>https://christitus.com/tags/git/</link><description>Recent content in Git on Chris Titus Tech | Tech Content Creator</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><managingEditor>Chris Titus</managingEditor><webMaster>Chris Titus</webMaster><lastBuildDate>Mon, 01 Sep 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://christitus.com/tags/git/index.xml" rel="self" type="application/rss+xml"/><item><title>Patching Programs From Forks</title><link>https://christitus.com/patching-programs-from-forks/</link><pubDate>Mon, 01 Sep 2025 00:00:00 +0000</pubDate><author>Chris Titus</author><guid>https://christitus.com/patching-programs-from-forks/</guid><description>&lt;p&gt;This article explains how to patch programs from forks using Git. It covers the steps to clone a forked repository, create a patch file, and apply it to the original repository.&lt;/p&gt;
&lt;h2 id="creating-patch-files"&gt;Creating Patch Files&lt;/h2&gt;
&lt;p&gt;Go to the repo that is ahead of the project that you want patched.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git format-patch -1 &amp;lt;COMMITSHA&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Git commit sha located at:&lt;/p&gt;
&lt;p&gt;
&lt;img loading="lazy" decoding="async" src="https://christitus.com/images/2025/git-sha.webp" alt="git-sha" class="img-fluid"&gt;
&lt;/p&gt;
&lt;h2 id="patching-the-original-repo"&gt;Patching the Original Repo&lt;/h2&gt;
&lt;p&gt;Check the stats and if there will be any rejects from patching&lt;/p&gt;
&lt;p&gt;Stats:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git apply --stat &amp;lt;PATCHFILE&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check for rejects:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git apply --check &amp;lt;PATCHFILE&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Apply a clean patch:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git am &amp;lt;PATCHFILE&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Apply a patch with rejects:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git am --reject &amp;lt;PATCHFILE&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Note: You may need to resolve conflicts manually if there are rejects. Look in the directory for any &lt;code&gt;*.rej&lt;/code&gt; and manually fix the lines that did NOT get applied!&lt;/p&gt;</description></item></channel></rss>