## Git Functions ## Git Commit function gac() { if [ -d ".git" ]; then echo "Log Message: " read logmessage git add --all && git commit --allow-empty-message -m "$logmessage" else echo "No .git Folder found in Directory. Are you in the Correct Folder?" fi } ## Git Push function gpm() { if [ "$(grep -c "[branch "master"]" .git/config )" -gt 0 ]; then git push origin master elif [ "$(grep -c "[branch "main"]" .git/config )" -gt 0 ]; then git push origin main else echo "fatal: not a git repository (or any of the parent directories): .git" fi } ## Git Pull All ## Pull all Git repos in this dir function pullall() { for dir in * ; do # Execute in subshell ( cd "$dir" || exit 1 # If it's a git directory, then update it if test -d .git; then # Check if its Master or Main if [ "$(grep -c -i ""master"" .git/config )" -gt 0 ]; then echo "$dir is a Git repo. Pulling master branch..." && git checkout master && git pull && echo "" elif [ "$(grep -c -i ""main"" .git/config )" -gt 0 ]; then echo "$dir is a Git repo. Pulling main branch..." && git checkout main && git pull && echo "" fi else echo "$dir is not a Git repo." && echo "" fi ) done }