Determine if the current directory is in a git repository. Returns true if so, false otherwise. This is mostly for use in other scripts, so that they can abort if run outside a git repo.
if git in-repo; then git status else echo "Not in a git repository" fi
Run a single git command in all subdirectories
Run a git command in each subdirectory of the current directory:
git subdirs COMMAND
Same, but with write permissions.
git subdirs --allow-write COMMAND
This command will run
git COMMAND in each subdirectory of the
current directory if that subdirectory is a git repository, By
default, it uses
unionfs-fuse to run git in a read-only view of the
repository. This allows you to run commands to query the status of
each repository such as
log without risk of
accidentally damaging many repositories at once with a command like
branch -D master.
unionfs-fuse is unavailable, read-only mode is disabled.
You can use the
--allow-write option to run a command that modifies
the repositories. I recommend that you think carefully before using
If the current directory is inside a git repository, this command will
do nothing, and suggest that you simply run
git COMMAND instead.
This was not originally written by me. The original is from http://jengelh.medozas.de/projects/hxtools/. I made some minor modifications to it. You'll have to diff it with the original to see.
Returns true if the current directory is inside a git repository and that repository has at least one commit.
git init && touch .gitignore && git commit .gitignore -m "Initial commit"
except that if the repository already has a commit in it, it just does