Re-define Git sub-commands
We can use the following method to re-define any Git sub-commands:
git config --global alias.st status
The above command allow us to shorten git status to git st.
We can also configure ~/.gitconfig directly.
# ~/.gitconfig
[alias]
st = status
pl = pull
plo = pull origin
pll = pull --all
pu = push
po = push origin
pam = push origin main
After saving the configuration file, we can utilize it like the below:
git st
git pl
git pl origin
git plo
git pl --all
git pll
git pu origin main
git po main
git pam
This only replaces the sub-command followed by the command git. If you want to create a shortcut that includes the git command, you can achieve that by creating a shell alias in .zshrc or .bashrc.