How i do git add, commit, and push with a single command
Office is on fire 🔥, Push the code to git.
Are you ever in a situation when you commit the code and forgot to push it? and your co-developer is awaiting for the new bug fixes you made.
git add .
git commit -m "fixed display name in the profile page"
# you forgets to run the git push command
what if i say running below command does add, commit and push for me.
gitacp "fixed display name in the profile page"
in order to use the above command, you need to edit your ~/.bashrc
or ~/.zshrc
file and apped the below code.
and run source ~/.bashrc
or source ~/.zshrc
to reflect the changes.
function gitacp() {
if [ -z "$1" ]; then
echo "Please provide a commit message."
return 1
fi
git add .
git commit -m "$1"
git push
}
Now you can have the ability to run the command like below and forget about pushing the code manually.
gitacp "added navbar"
It’s gonna run git add .
and git commit -m "added navbar"
and git push
for you.