Created
March 29, 2021 19:26
-
-
Save hritik5102/de6a6e9d2092310f40736e1b9e1d93b7 to your computer and use it in GitHub Desktop.
Automate repetitive tasks with custom Git commands
This file contains hidden or 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/sh | |
# Run the file inside terminal | |
# $ bash git-automation.sh "Commit message" | |
echo "Git Automation Starts ....." | |
message=$1 # First parameter will be the commit message | |
currentBranch=$(git symbolic-ref --short -q HEAD) # Getting the current branch | |
if [ ! -z "$1" ] # checking if the commit message is present. If not then aborting. | |
then | |
git status | |
read -p "Do you want to push the changes ? [Y/N] : " user_var | |
if [[ "$user_var" == "y" || "$user_var" == "Y" || "$user_var" == "yes" ]] | |
then | |
git add . | |
git commit -m "$message" | |
git push origin $currentBranch | |
else | |
echo "Pushing changes is incomplete" | |
fi | |
else | |
echo "Commit message is not provided" | |
fi # closes the if statement |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference : Level up coding - automate repetitive tasks with custom git commands