<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>emre şahin's digital garden 🍃 - git</title>
    <link>https://emresahin.net/categories/git/</link>
    <description>Posts in the git category</description>
    <language>en</language>
    <managingEditor>contact@emresahin.net (Emre Şahin)</managingEditor>
    <lastBuildDate>Tue, 15 Sep 2026 19:46:32 +0000</lastBuildDate>
    <atom:link href="https://emresahin.net/categories/git/rss.xml" rel="self" type="application/rss+xml"/>
    <item>
      <title>devlog 7</title>
      <published>2024-08-06T06:43:01+00:00</published>
      <updated>2024-08-06T06:43:01+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Tue, 06 Aug 2024 06:43:01 +0000</pubDate>
      <link>https://emresahin.net/devlog-7/</link>
      <guid isPermaLink="true">https://emresahin.net/devlog-7/</guid>
      <description>I noticed that I often forget to update the Xvc CHANGELOG. To fix this, I added a pre-push hook that checks the files I’m pushing. If the CHANGELOG is not among them and there are changes to Rust files, it prevents the push. I hope this will remind me to update the logs more frequently. #!/bin/ba...</description>
      <category>devlog</category>
      <category>Software Development</category>
      <category>Git</category>
      <category>git-hooks</category>
      <category>automation</category>
      <category>changelog</category>
      <category>xvc</category>
      <category>bash</category>
      <content:encoded><![CDATA[<p>I noticed that I often forget to update the Xvc CHANGELOG. To fix this, I added
a pre-push hook that checks the files I’m pushing. If the CHANGELOG is not among
them and there are changes to Rust files, it prevents the push. I hope this will
remind me to update the logs more frequently.</p>
<pre><code class="language-bash">#!/bin/bash

# Git pre-push hook to check if CHANGELOG.md is included in the push and if the branch is develop

# Get the current branch name

current_branch=$(git rev-parse --abbrev-ref HEAD)

# Check if the branch is develop

if [ "$current_branch" == "main" ]; then
	echo "You are on the main branch. Skipping CHANGELOG.md check."
	exit 0
fi

# remote="$1"
# url="$2"

# Get the list of commits to be pushed
commits=$(git rev-list '@{u}..HEAD')

has_rust_files=$(false)

# TODO: We can iterate to get file list only once
# Get the list of files that are going to be pushed
for commit in $commits; do
	if git diff-tree --no-commit-id --name-only -r "${commit}" | grep -q "\\.rs$"; then
		has_rust_files=$(true)
	fi
done

if [[ ! $has_rust_files ]]; then
	echo "No .rs files in the push, no need to check CHANGELOG"
	exit 0
fi

# Check if CHANGELOG.md is among the files in the commits
for commit in $commits; do
	if git diff-tree --no-commit-id --name-only -r "${commit}" | grep -q "CHANGELOG.md"; then
		echo "CHANGELOG.md is included in the push."
		exit 0
	fi
done

echo "ERROR: CHANGELOG.md is not included in the push."
exit 1
</code></pre>
<p><strong>Edit (2025-02-08):</strong> Added a check for when only code files are changed.</p>]]></content:encoded>
    </item>
    <item>
      <title>Global .gitignore</title>
      <published>2023-10-17T13:11:34+00:00</published>
      <updated>2023-10-17T13:11:34+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Tue, 17 Oct 2023 13:11:34 +0000</pubDate>
      <link>https://emresahin.net/gitignore_global/</link>
      <guid isPermaLink="true">https://emresahin.net/gitignore_global/</guid>
      <description>You can configure a global .gitignore file to ignore files or directories (e.g., .vscode/ ) in all your repositories. Write it as a standard .gitignore file and save it somewhere, like ~/.gitignore_global . Then, you can use the following configuration to set this as an excludes file : git config...</description>
      <category>til</category>
      <category>git</category>
      <category>git</category>
      <category>configuration</category>
      <category>tips</category>
      <content:encoded><![CDATA[<p>You can configure a global <code>.gitignore</code> file to ignore files or directories (e.g., <code>.vscode/</code>) in all your repositories. Write it as a standard <code>.gitignore</code> file and save it somewhere, like <code>~/.gitignore_global</code>. Then, you can use the following configuration to set this as an <em>excludes file</em>:</p>
<pre><code class="language-bash">git config --global core.excludesfile ~/.gitignore_global
</code></pre>
<p>Note that the path given to <code>git config</code> should be an absolute path.</p>]]></content:encoded>
    </item>
  </channel>
</rss>
