Last active
May 4, 2019 10:51
-
-
Save chris-moreton/a5b246ad9f8a65d1fceeb26f1951982d to your computer and use it in GitHub Desktop.
Bash function to push all changes to your Git repo from any subdirectory
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
# A simple function that shows the changed files relative to the root, asks if you want to | |
# commit all the changes, and then commits and pushes with a given commit messasge. | |
# | |
# Usage gpush "This is a commit message" | |
function gpush() { | |
RETURN_CMD="cd $PWD" | |
while [ ! -d ".git" ] | |
do | |
if [ $PWD == '/' ] | |
then | |
exit | |
fi | |
cd .. | |
done | |
git status | |
read -p "Shall we push all this? " SHALL_WE | |
if [ $SHALL_WE == "y" ] | |
then | |
git add -A | |
git commit -m "$1" | |
git push | |
fi | |
eval $RETURN_CMD | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment