mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
When those commands are used outside a git repo, 'Not a git repo!' will be printed to stderr
15 lines
240 B
Plaintext
Executable file
15 lines
240 B
Plaintext
Executable file
#
|
|
# check whether current directory is inside a git repository
|
|
#
|
|
|
|
is_git_repo() {
|
|
git rev-parse --show-toplevel > /dev/null 2>&1
|
|
result=$?
|
|
if test $result != 0; then
|
|
>&2 echo 'Not a git repo!'
|
|
exit $result
|
|
fi
|
|
}
|
|
|
|
is_git_repo
|