You can very easily automate this using Bash scripting.
git add .
echo 'Enter the commit message:'
read commitMessage
git commit -m "$commitMessage"
echo 'Enter the name of the branch:'
read branch
git push origin $branch
read
store the above code as a .sh
file(say gitpush.sh
)
And since you have to make this sh file an executable you need to run the following command in the terminal once:
chmod +x gitpush.sh
And now run this .sh
file.
Each time you run it, It will ask you for the commit message and the name of the branch. In case the branch does not exist or the push destination is not defined then git will generate an error. TO read this error, I have added the last read
statement. If there are no errors, then git generates the pushed successfully
type-of message.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…