repo is a tool that recursively finds git repositories on a filesystem. It can include only repositories matching certain state (dirty, unpushed) and exclude any that match patterns defined in a configuration file. The two modes of operation are to list paths (ls
) or execute (run
) commands in the context of the repository.
Usage:
repo [options] ls
repo [options] run [--] <command>...
Find git repository paths starting from the current directory, or from stdin if supplied.
Paths from stdin are always displayed as absolute paths.
Options:
-d, --dirty Include only dirty repositories
-u, --unpushed Include only unpushed repositories
-a, --all Include ignored repositories
-x, --absolute Show absolute paths
-v, --verbose Show a header for each repository when executing a command
-i, --interactive Pause between command executions
--ignore-errors Ignore errors when executing commands
Find repositories you've left uncommitted changes in.
repo -d ls
Find repositories you've left unpushed commits in.
repo -u ls
Push all repositories you've left unpushed commits in.
repo -vu run git push
Check the status of all repositories.
repo -v run -- git status -sb
Run fsck on all repositories.
repo -v run git fsck
Perform garbage collection on all repositories, and show a total file count of the .git
directories before and after.
repo run -- bash -c 'find .git/ -type f | wc -l' | paste -sd+ | bc
repo -v run git gc
repo run -- bash -c 'find .git/ -type f | wc -l' | paste -sd+ | bc
If a config file containing gitignore patterns exists at $HOME/.config/repo/ignore
then absolute repository paths will be matched against this file using the high-performance ignore crate.
As absolute repository paths are used to match against the ignore rules the ignore pattern file should be written as though its root is /
, the root of the filesystem. This means that if the pattern contains a /
then it must be either absolute or prefixed with a **/
to match.
.cargo/ # Match ".cargo" as any component of path.
**/.cargo/registry/ # Match just the "registry" subdirectory.
**/.local/share/Trash/ # Ignore trash.
Ensure rust
is installed.
cargo build --release
The binary can be found in target/release
.
When benchmarked the git2 crate performed worse than spawning git processes to do the same job. Yes, this disappointed me too.
Open an issue or send a pull request.