Skip to content

Instantly share code, notes, and snippets.

@chlab
Last active September 11, 2015 12:44
Show Gist options
  • Save chlab/9f95b2f4caa2492f8d7d to your computer and use it in GitHub Desktop.
Save chlab/9f95b2f4caa2492f8d7d to your computer and use it in GitHub Desktop.
Git: show all files you changed between two git commits
#!/bin/sh
# get git user from git config
gituser="$(git config user.email)"
# tell user how to set git user if we didn't get one
if [ -z "$gituser" ]; then
echo "Please configure your git user:"
echo "git config --global user.name \"your name\""
echo "git config --global user.email \"your email\""
exit 1
fi
# we need at least two args
if [ $# -lt 2 ]; then
echo "Usage: $0 <commit-hash-from> <commit-hash-to>"
exit 1
fi
git log --pretty="%H" --author="$gituser" $1..$2 | while read commit_hash; do git show --oneline --name-only $commit_hash | tail -n+2; done | sort | uniq
@chlab
Copy link
Author

chlab commented Aug 10, 2015

This is a little script I use to find all files I changed between two git commits.
Drop this script into your repo somewhere and use like:

./git_changed_files.sh commithash1 commithash2

Inspired by http://stackoverflow.com/a/6349405/682583

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