April 17, 2018 · EN snippets

Shorten default git commit process

When you need rush, it's hard to type all the repetitive commands. One such case appears with standard git commit process. You make atomic changes/additions and commit them with short descriptions, then push to the master/other branch.

There's a shorthand configuration for this process to be done in a matter of keyboard taps. Just make the following config and you are good to go:

git config --global alias.c '!git add --all && git commit -m'
git config --global alias.p '!git push -u origin master'

With the above config, you type git c following with a commit description to add all the changes and commit them. You type git p to push them to the master branch.

git c 'change commit'
git p

[source: https://stackoverflow.com/questions/4298960/git-add-and-commit-in-one-command]