Skip to content

Instantly share code, notes, and snippets.

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 kevinhooke/389b4e69d3f2ea7c95dc248e8cdd91f3 to your computer and use it in GitHub Desktop.
Save kevinhooke/389b4e69d3f2ea7c95dc248e8cdd91f3 to your computer and use it in GitHub Desktop.
git list files on a commit and delete files and all history
# diff changed files against previous commit - this doesn't show anything for a first commit
git diff-tree --no-commit-id --name-only -r commithash
# list all files on a commit
git ls-tree --name-only -r commithash
# delete a file from all commit history
git filter-branch --tree-filter "rm -f filename" HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment