Skip to content

Instantly share code, notes, and snippets.

@strezh
Created November 20, 2023 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strezh/0774e608c902056b494577bfb5ce0146 to your computer and use it in GitHub Desktop.
Save strezh/0774e608c902056b494577bfb5ce0146 to your computer and use it in GitHub Desktop.
git: save all changed file tree between versions

Get tree of changed files between versions and save it to TAR archive

git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT $commit_id | xargs tar -rf mytarfile.tar
  1. git diff-tree -r $commit_id: - Take a diff of the given commit to its parent(s) (including all subdirectories, not just the top directory).
  2. --no-commit-id --name-only: - Do not output the commit SHA1. Output only the names of the affected files instead of a full diff.
  3. --diff-filter=ACMRT: - Only show files added, copied, modified, renamed or that had their type changed (eg. file → symlink) in this commit. This leaves out deleted files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment