A tool (cli & lib) to find and broadcast commands on local git repositories.
Because I need a tool to list and to reorg my local git repositories.
```sh $> git find -h git-find 0.5.0 davidB A tool (cli & lib) to find local git repositories.
USAGE: git-find [FLAGS] [OPTIONS] [DIR]
FLAGS: -h, --help Prints help information -V, --version Prints version information -v, --verbose Verbose mode (-v, -vv, -vvv, etc.) print on stderr
OPTIONS:
-t, --tmpl
ARGS:
sample output with default template (M : Modification uncommitted, U: Untracked)
sh
$> git-find .
sbt-scalabuff /home/dwayne/src/github.com/sbt/sbt-scalabuff origin https://github.com/sbt/sbt-scalabuff.git
MU ML /home/dwayne/src/github.com/samynk/ML origin https://github.com/samynk/ML.git
BlenderSourceTools /home/dwayne/src/github.com/Artfunkel/BlenderSourceTools origin git@github.com:Artfunkel/BlenderSourceTools.git
three.js /home/dwayne/src/github.com/mrdoob/three.js origin git@github.com:mrdoob/three.js.git
MU Yadef /home/dwayne/src/github.com/zzuegg/Yadef origin git@github.com:zzuegg/Yadef.git
MU dmonkey /home/dwayne/src/github.com/kwando/dmonkey origin https://github.com/kwando/dmonkey.git
MU getdown /home/dwayne/src/github.com/threerings/getdown origin https://github.com/threerings/getdown.git
dart-protoc-plugin /home/dwayne/src/github.com/dart-lang/dart-protoc-plugin origin git@github.com:dart-lang/dart-protoc-plugin.git
M vdrones /home/dwayne/src/github.com/davidB/vdrones origin git@github.com:davidB/vdrones.git
shader_editor /home/dwayne/src/github.com/davidB/shader_editor origin git@github.com:davidB/shader_editor.git
scala-maven-plugin /home/dwayne/src/github.com/davidB/scala-maven-plugin origin git@github.com:davidB/scala-maven-plugin.git
simpleaudio /home/dwayne/src/github.com/davidB/simpleaudio origin git@github.com:davidB/simpleaudio.git
MU ld31_p0cm0n /home/dwayne/src/github.com/davidB/ld31_p0cm0n origin git@github.com:davidB/ld31_p0cm0n.git
livereload-jvm /home/dwayne/src/github.com/davidB/livereload-jvm origin git@github.com:davidB/livereload-jvm.git
dart-protobuf /home/dwayne/src/github.com/davidB/dart-protobuf origin git@github.com:davidB/dart-protobuf.git
U jme3_skel /home/dwayne/src/github.com/davidB/jme3_skel origin git@github.com:davidB/jme3_skel.git
asset_pack /home/dwayne/src/github.com/davidB/asset_pack origin git@github.com:davidB/asset_pack.git
git-find /home/dwayne/src/github.com/davidB/git-find origin git@github.com:davidB/git-find.git
jme3_ext_assettools /home/dwayne/src/github.com/davidB/jme3_ext_assettools origin git@github.com:davidB/jme3_ext_assettools.git
...
broadcast git status
to every repositories
sh
git find -t 'cd {{ .path.full }}; echo "\n\n----\n$PWD"; git status' | sh
clean git repository (to free space)
sh
git find -t 'cd {{ .path.full }} && git clean -d -X -f' | sh
The template format is a subset of golang text/template.
!! Experimental: values could change with future release !!
If the template is a shell script (the tips could be used with every interpreter: python, ruby, ...), then you can
```sh
git find -t '...' | sh
git find -t '...' > myscript.sh sh myscript.sh
```
to list local repository
tmpl
{{ .path.file_name }}\t{{ .path.full }}
to list local repository with origin url
```tmpl {{ .path.filename }}\t{{ .path.full }}\t{{with .remotes.origin}} {{ .name }} {{.urlfull}} {{.urlhost}} {{.urlpath}} {{end}} ````
to create a sh script to "git fetch" on every repository
tmpl
cd {{ .path.full }}; echo "\n\n---------------------------------------------\n$PWD"; git fetch
to create a sh script to move git repository under $HOME/src (same layout as go workspace)
```tmpl echo "\n\n---------------------------------------------\n" PRJSRC="{{ .path.full }}" {{if .remotes.origin}} PRJDST="$HOME/src/{{ .remotes.origin.urlhost }}/{{ .remotes.origin.urlpath}}" {{else}} PRJDST=$HOME/src/local/{{ .path.filename}} {{end}} if [ ! -d "$PRJDST" ] ; then read -p "move $PRJSRC to $PRJDST ?" answer case $answer in [yY]* ) mkdir -p $(dirname "$PRJDST") mv "$PRJSRC" "$PRJDST" ;;
to list repo with some info (the default template of version 0.4.1)
tmpl
{{with .working_paths}}{{if .conflicted}}C{{else}} {{end}}{{if .modified}}M{{else}}{{if .added}}M{{else}}{{if .deleted}}M{{else}}{{if .renamed}}M{{else}} {{end}}{{end}}{{end}}{{end}}{{if .untracked}}U{{else}} {{end}}{{end}}\t{{ .path.file_name }}\t{{ .path.full }}\t{{with .remotes.origin}} {{ .name }} {{.url_full}} {{end}}
With Rust's package manager cargo, you can install via:
sh
cargo install git-find
Note that rust version 1.26.0 or later is required.
!! Experimental !!
The release page includes precompiled binaries for Linux, macOS and Windows.
sh
tar -xzvf git-find_0.3.2-x86_64-unknown-linux-gnu.tar.gz
chmod a+x git-find
mv git-find $HOME/bin
rm git-find_0.2.2-linux.tar.gz
```sh git clone https://github.com/davidB/git-find
cd git-find cargo build
cargo test
cargo install ```
Some tools to help management of multi repository But not the same features, else no need to re-do.