Skip to content

Instantly share code, notes, and snippets.

@akrez
Last active January 6, 2026 09:29
Show Gist options
  • Select an option

  • Save akrez/f9b42300fc04f7a4cb659b6e08ec27ac to your computer and use it in GitHub Desktop.

Select an option

Save akrez/f9b42300fc04f7a4cb659b6e08ec27ac to your computer and use it in GitHub Desktop.
commit changes to new file
#!/bin/bash
COMMIT_HASH=$1
# Get changed files and copy them
git show --name-only --pretty=format: $COMMIT_HASH | while read file; do
if [ -n "$file" ] && [ -f "$file" ]; then
echo "================== FILE: $file =================="
cat "$file"
fi
done
{
git diff --name-only --cached
git diff --name-only
git ls-files --others --exclude-standard
} | sort | uniq | grep -v '^ch\.txt$' | while read file; do
if [ -n "$file" ] && [ -f "$file" ]; then
echo "================== FILE: $file =================="
cat "$file"
fi
done > ch.txt
find . \
-path ./.git -prune -o \
-name ch.txt -prune -o \
-type f -print |
sort -u |
while read -r file; do
echo "================== FILE: $file =================="
cat "$file"
done > ch.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment