<?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 Kenno&#39;s Open Note</title>
    <link>https://blog.khmersite.net/tags/git/</link>
    <description>Recent content in Git on Kenno&#39;s Open Note</description>
    <image>
      <title>Kenno&#39;s Open Note</title>
      <url>https://blog.khmersite.net/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://blog.khmersite.net/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo -- 0.154.0</generator>
    <language>en</language>
    <lastBuildDate>Sat, 20 Dec 2025 01:33:59 +1100</lastBuildDate>
    <atom:link href="https://blog.khmersite.net/tags/git/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>How to undo a pushed commit</title>
      <link>https://blog.khmersite.net/p/how-to-undo-a-pushed-commit/</link>
      <pubDate>Sat, 20 Dec 2025 01:33:59 +1100</pubDate>
      <guid>https://blog.khmersite.net/p/how-to-undo-a-pushed-commit/</guid>
      <description>&lt;p&gt;Oops&amp;hellip; I just accidentally pushed a git commit containing code with a secret in plain text to a remote repo! Though it&amp;rsquo;s a &lt;strong&gt;private&lt;/strong&gt; repository, I want to clean this mess up for security best practice. So, let&amp;rsquo;s fix it!&lt;/p&gt;
&lt;p&gt;Here are the last two commits. The secret resides in one of the files from the &amp;ldquo;add argocd infra to git&amp;rdquo; commit.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ git log -2
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;commit fe7b0510edc4fb160a16421352ba598e3f62703e &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;HEAD -&amp;gt; main, origin/main, origin/HEAD&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Author: kenno &amp;lt;kenno@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Date:   Sat Dec &lt;span style=&#34;color:#ae81ff&#34;&gt;20&lt;/span&gt; 00:59:36 &lt;span style=&#34;color:#ae81ff&#34;&gt;2025&lt;/span&gt; +1100
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    add argocd infra to git
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;commit c5a75ae14cf3528db1fea7677e2bdb54167037cd
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Author: kenno &amp;lt;kenno@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Date:   Thu Dec &lt;span style=&#34;color:#ae81ff&#34;&gt;18&lt;/span&gt; 14:38:17 &lt;span style=&#34;color:#ae81ff&#34;&gt;2025&lt;/span&gt; +1100
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    add basic auth middleware to longhorn httproute
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Since the commit had already been pushed to a remote repository, simply &amp;ldquo;undoing&amp;rdquo; the commit locally is not enough; it is required to overwrite the remote history.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to revert a single file to its state in main in branch</title>
      <link>https://blog.khmersite.net/p/how-to-revert-a-single-file-to-main-in-git/</link>
      <pubDate>Fri, 28 Feb 2025 15:19:48 +1100</pubDate>
      <guid>https://blog.khmersite.net/p/how-to-revert-a-single-file-to-main-in-git/</guid>
      <description>&lt;p&gt;I want to reset a file stored in a git repo to its state as the main branch, and I kept forgetting how to do this.&lt;/p&gt;
&lt;p&gt;So here is how, just to remind my future self.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;➜ git status
On branch main
Your branch is up to date with &amp;#39;origin/main&amp;#39;.

Changes not staged for commit:
  (use &amp;#34;git add &amp;lt;file&amp;gt;...&amp;#34; to update what will be committed)
  (use &amp;#34;git restore &amp;lt;file&amp;gt;...&amp;#34; to discard changes in working directory)
        modified:   kube-prometheus-stack-values.yaml

no changes added to commit (use &amp;#34;git add&amp;#34; and/or &amp;#34;git commit -a&amp;#34;)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The above output shows that there is a modified file, &lt;code&gt;kube-prometheus-stack-values.yaml&lt;/code&gt; that is not yet staged for commit.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Changing Hugo Theme</title>
      <link>https://blog.khmersite.net/p/changing-hugo-theme/</link>
      <pubDate>Tue, 20 Jun 2023 22:36:37 +1000</pubDate>
      <guid>https://blog.khmersite.net/p/changing-hugo-theme/</guid>
      <description>&lt;p&gt;Had you visited this blog recently, you may have noticed that the blog&amp;rsquo;s theme has changed.&lt;/p&gt;
&lt;p&gt;Here is a quick note on how I changed the theme of this blog from &lt;strong&gt;cayman-hugo-theme&lt;/strong&gt; to &lt;strong&gt;PaperMod&lt;/strong&gt;. For a little background, Hugo themes are installed
as git submodule. Want a quick recap on how to use Git Submodule? Here is a good content [0].&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;First, the current theme needs to be removed:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ git submodule
4a924cef54081b61530a30bd69d442ae99916561 themes/cayman-hugo-theme (heads/master)

$ git submodule deinit &amp;#34;themes/cayman-hugo-theme&amp;#34;
$ git rm &amp;#34;themes/cayman-hugo-theme&amp;#34;

$ git commit -m &amp;#39;remove theme cayman-hugo-theme&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;Add a new theme, &lt;strong&gt;PaperMod&lt;/strong&gt; [2] as the submodule.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ git submodule add --depth=1 https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod
$ git add .gitmodules
$ git add config.yml

$ git commit -m &amp;#39;change theme to PaperMod&amp;#39;
$ git push
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Note: As each Hugo theme contains specific parameters, I also had to update the &lt;code&gt;config.yml&lt;/code&gt; required by this new theme. A copy of a sample &lt;code&gt;config.yml&lt;/code&gt;
is available at the theme&amp;rsquo;s &lt;a href=&#34;https://github.com/adityatelange/hugo-PaperMod/tree/exampleSite/&#34;&gt;exampleSite&lt;/a&gt; [1].&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to add additional remote git repository</title>
      <link>https://blog.khmersite.net/p/how-to-add-additonal-remote-git-repo/</link>
      <pubDate>Sat, 03 Sep 2022 12:24:10 +1000</pubDate>
      <guid>https://blog.khmersite.net/p/how-to-add-additonal-remote-git-repo/</guid>
      <description>&lt;p&gt;Though it&amp;rsquo;s not very common in my daily work, I occasionally need to add additional remote Git repositories mainly for pushing. In fact, I did this about 4 to 5 times already, and thought that it&amp;rsquo;d be the last time.&lt;/p&gt;
&lt;p&gt;Today, I need do this again, and I forgot!&lt;/p&gt;
&lt;p&gt;Currently, I have the following remote repository set for &amp;lsquo;origin&amp;rsquo;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;❯ git remote -v
origin  git@git.homeserver.local:kenno/ansible.git (fetch)
origin  git@git.homeserver.local:kenno/ansible.git (push)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I wanted to add &lt;code&gt;https://kenno@gitea.homeserver.local/kenno/ansible.git&lt;/code&gt; as the additional repo for pushing.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Installing Xcode Command Line Tools</title>
      <link>https://blog.khmersite.net/p/installing-xcode-command-line-tools/</link>
      <pubDate>Thu, 25 Feb 2021 23:03:17 +1100</pubDate>
      <guid>https://blog.khmersite.net/p/installing-xcode-command-line-tools/</guid>
      <description>&lt;p&gt;I need to use &lt;code&gt;git&lt;/code&gt; on command line on macOS 11 (Big Sur), and &lt;code&gt;git&lt;/code&gt; comes with command line developer tools. Here is how it can be done on macOS:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-console&#34; data-lang=&#34;console&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;❯ xcode-select --install
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;xcode-select: note: install requested for command line developer tools
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;On a side note, I notice that every time there is an update to Big Sur, I also have to re-install this Xcode Command Line Tools.&lt;/p&gt;
&lt;p&gt;Ref:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://gist.github.com/kamermanpr/23bc20180dc277bc8043558f0c22f8a9&#34;&gt;kamermanpr/install-xcodeCLT-homebrew-git.md&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
    <item>
      <title>FreeBSD git fatal: Unable to find remote helper for &#39;https&#39;</title>
      <link>https://blog.khmersite.net/p/freebsd-git-fatal-unable-to-find-remote-helper-for-https/</link>
      <pubDate>Fri, 01 Jul 2016 23:15:03 +0000</pubDate>
      <guid>https://blog.khmersite.net/p/freebsd-git-fatal-unable-to-find-remote-helper-for-https/</guid>
      <description>&lt;p&gt;I just found out that git is not fully functional on my FreeBSD (11) box. It was installed from port (using &lt;code&gt;portmaster git&lt;/code&gt;). I can clone a repo using SSH key, but not with HTTPS.&lt;/p&gt;
&lt;p&gt;I’m not quite sure if it’s always been this way. Here is how to fix it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Reinstall &lt;code&gt;curl&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-console&#34; data-lang=&#34;console&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# pkg remove curl
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# portmaster curl
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;Reinstall &lt;code&gt;git&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-console&#34; data-lang=&#34;console&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# pkg remove git
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;# portmaster git
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Why did I install &lt;code&gt;git&lt;/code&gt; from port? Well, &amp;lsquo;cuz there is no binary package for FreeBSD 11 arm, which runs on my Raspberry Pi B+.&lt;/p&gt;</description>
    </item>
    <item>
      <title>ការបញ្ចូល git ក្នុង Raspberry Pi ដើរ​ FreeBSD 11</title>
      <link>https://blog.khmersite.net/p/installing-git-command-on-raspberrypi-freebsd11/</link>
      <pubDate>Fri, 29 May 2015 21:36:56 +0000</pubDate>
      <guid>https://blog.khmersite.net/p/installing-git-command-on-raspberrypi-freebsd11/</guid>
      <description>&lt;p&gt;ដោយ​សារ​ពុំមាន​ កញ្ចប់បាយនារី (binary package) នៃ​​ git យើង​​ត្រូវ​បញ្ចូល​ git​ពីសោះ​ខូត ដូច​ខាងក្រោម៖&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# cd /usr/ports/devel/git
# make install clean
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;សង្ឃឹម​ថា​ថ្ងៃ​ក្រោយ​ឆាប់ៗ កញ្ចប់​បាយនារី នឹង​បាន​បង្កើត​ឡើង​ ព្រោះខំផាយ​ពី សោះខូត​យើត​ណាស់ ជាពិសេស​ពេល​ខំផាយ​វា​លើ​ រ៉ាស់​ប៊ែរី​ផាយ។&lt;/p&gt;</description>
    </item>
    <item>
      <title>Turn color on for git status</title>
      <link>https://blog.khmersite.net/p/turn-color-on-for-git-status/</link>
      <pubDate>Thu, 26 Sep 2013 03:49:33 +0000</pubDate>
      <guid>https://blog.khmersite.net/p/turn-color-on-for-git-status/</guid>
      <description>&lt;p&gt;The following command will update the Git&amp;rsquo;s global configuration to set the &lt;code&gt;color.ui&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ git config --global color.ui true
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;Ref: &lt;a href=&#34;https://ask.fedoraproject.org/question/10434/f18-why-are-there-no-gnome-terminal-colors-for-git/&#34;&gt;https://ask.fedoraproject.org/question/10434&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Beautify gitk font on Debian/Ubuntu</title>
      <link>https://blog.khmersite.net/p/beautify-gitk-font-on-debianubuntu/</link>
      <pubDate>Sun, 04 Sep 2011 11:35:11 +0000</pubDate>
      <guid>https://blog.khmersite.net/p/beautify-gitk-font-on-debianubuntu/</guid>
      <description>&lt;p&gt;Install tk8.5, if not yet installed:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# apt-get install tk8.5
# update-alternatives --config wish

  Selection    Alternative
-----------------------------------------------
          1    /usr/bin/wish8.4
*+        2    /usr/bin/wish-default
          3    /usr/bin/wish8.5&amp;lt;/pre&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;There are 3 alternatives which provide &lt;code&gt;wish&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Type in the number that corresponds to &lt;code&gt;tk8.5&lt;/code&gt; (in my case was 3) then hit enter.&lt;/p&gt;
&lt;p&gt;Change fonts in &lt;code&gt;~/.gitk&lt;/code&gt; to &lt;code&gt;DejaVu Sans Mono&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;set mainfont {{DejaVu Sans Mono} 9}
set textfont {{DejaVu Sans Mono} 9}
set uifont {{DejaVu Sans Mono} 9 bold}
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
  </channel>
</rss>
