GIT: Add, Commit, And push all at once
We'll make a bash script that will do git add -A; git commit -m "..."; git push
, exiting if you use an empty commit message
Create a file, give it execute permission, and open it for editing. You don't have to use the bin
directory. But for now, we are.
cd ~/;
mkdir bin;
cd bin;
touch gitamp; # The file name IS the command name. you can make it whatever you like.
chmod +x gitamp;
nano gitamp;
Now, copy+paste the following bash script into the gitamp
file.
echo "git add, commit, push from: "; pwd;
read -p "Enter Commit Message:" msg;
case $msg in
"" ) echo "Empty commit message. Exiting";exit;;
esac
git add -A;
git commit -m "$msg";
git push;
Now, you can ~/bin/gitamp
OR add it to your path, like so:
sudo nano ~/.bashrc
, and on the last line write export PATH=$PATH:~/bin
Then restart your terminal or enter source ~/.bashrc