Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Created July 23, 2024 13:38
Show Gist options
  • Save dongyuwei/82e08826e59cd07065ba213a4adf037a to your computer and use it in GitHub Desktop.
Save dongyuwei/82e08826e59cd07065ba213a4adf037a to your computer and use it in GitHub Desktop.
concat-files-in-git-repo.sh [HEAD or comit-hash]
#!/bin/bash
COMMIT_HASH=$1
git ls-tree --full-tree -r --name-only $COMMIT_HASH | while read -r file; do
echo "--- $file ---" >> all_files_contents.txt
git show $COMMIT_HASH:$file >> all_files_contents.txt
echo "" >> all_files_contents.txt
done
@dongyuwei
Copy link
Author

Usage: concat-files-in-git-repo.sh [HEAD or comit-hash]

  • concat-files-in-git-repo.sh HEAD
  • concat-files-in-git-repo.sh 65218c0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment