A bash script that exports your git commit history to a text file, with optional diffs.
mv export_commits ~/.local/bin/export_commits
chmod +x ~/.local/bin/export_commitsIf ~/.local/bin is not on your PATH, add this to your ~/.bashrc or ~/.zshrc:
export PATH="$HOME/.local/bin:$PATH"Then reload your shell:
source ~/.zshrc # or ~/.bashrcexport_commits [OPTIONS]Run from inside any git repository. The output file is created in the current directory.
| Flag | Description |
|---|---|
-d, --diff |
Include full diffs for each commit |
--no-author |
Omit author name and email from output |
--from TAG |
Export commits starting after this tag |
--to TAG |
Export commits up to and including this tag |
-o FILE |
Output file (default: commits.txt) |
-b BRANCH |
Branch to export (default: current branch) |
-n N |
Limit to the last N commits |
-a AUTHOR |
Filter commits by author name or email |
-s DATE |
Only commits after this date (e.g. 2024-01-01) |
-u DATE |
Only commits before this date |
-h, --help |
Show help message |
# All commits, basic log
export_commits
# All commits with diffs
export_commits --diff
# All commits, no author, with diffs
export_commits --no-author --diff
# Last 20 commits, saved to a custom file
export_commits -n 20 -o my_log.txt
# Commits from a specific author since a date
export_commits -a "jane@example.com" -s 2024-01-01
# Specific branch, with diffs, no author
export_commits -b main --diff --no-author -o main_log.txt
# Commits between two tags
export_commits --from v1.0.0 --to v2.0.0
# Commits between two tags, with diffs, no author
export_commits --from v1.0.0 --to v2.0.0 --diff --no-author
# All commits after a tag up to HEAD
export_commits --from v1.0.0Each commit entry contains:
- Full and short commit hash
- Author name and email (unless
--no-authoris used) - Date
- Subject and body
- Tags pointing to the commit (shows
—if none) - List of changed files
- Full diff (if
--diffis used)