Last active
August 29, 2015 14:20
-
-
Save csarrazi/9316710d031ba306aa0a to your computer and use it in GitHub Desktop.
Useful commands for working with git repositories from the outside, or managing multiple git repositories in the same folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rgit () { | |
if [[ "$#" -lt 2 ]]; then | |
echo "usage: rgit <repository-path> <command> [<args>]" | |
return 1 | |
fi | |
local worktree=$1 | |
shift | |
git -C $worktree $@ | |
} | |
multigit () { | |
if [[ "$#" -lt 2 ]]; then | |
echo "usage: multigit <repository-path> <command> [<args>]" | |
return 1 | |
fi | |
local folder=$1 | |
shift | |
cd "$folder" | |
find . -maxdepth 1 ! -path . -type d -print | while read -r i; do rgit "$i" $@; done; | |
cd - | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment