A minimal GNU-style find implementation for Git. This utility allows for pattern searching in the Git history and optionally take actions over it.
Delete all files greater than 1M from the history
git find --size +1M --delete
Delete all files that match '*.gz' from the history
git find --name '*.gz' --delete
Delete all files that match '*.txt' and are located within a 'reports' directory from the history
git find --name '*.gz' --path '*/reports/*' --delete
You can also specify an arbitrary command to execute. The following variables will be interpolated: %{mode}, %{type}, %{sha}, %{size}, %{path}
git find --name '*.gz' --path '*/reports/*' --exec 'git cat-files %{type} %{sha}'
Formatted output is implemented as follows
git find --printf '%{sha} %{path} %{size}'
and so forth.
The script needs to be made available on your PATH in order for git to have find as an additional command-line action.
- Implement -type option
- Implement find-alike expressions and operators (e.g. -name x -o -name y)
Matteo Cerutti - matteo.cerutti@hotmail.co.uk