git add foo, git commit foo, git push foo....
I only use basic git commands, but typing them out every time is cumbersome, so I decided to create some aliases.
Script
#git branch
alias git-b='git branch'
#git checkout
function gitCheckout() {
stty erase ^H
echo -n "What is the new branch name?"
stty echo
read var1
git checkout ${var1}
}
alias git-c=gitCheckout
#git checkout -b
function gitCheckoutBranch() {
stty erase ^H
echo -n "What is the new branch name for checkout?"
stty echo
read var1
git checkout -b ${var1}
}
alias git-c-b=gitCheckoutBranch
#git pull
function gitPull() {
stty erase ^H
echo -n "What is the remote repository name?"
stty echo
read var1
git pull origin ${var1}
}
alias git-p=gitPull
#git set
function gitSet() {
stty erase ^H
echo -n "What file name do you add?"
read var1
git add ${var1}
echo -n "What is the commit message?"
read var2
git commit -m\'${var2}\'
echo -n "What is the branch name?"
stty echo
read var3
git push origin ${var3}
}
alias git-set=gitSet
Command Descriptions
- git-b ...Check branches
- git-c ...Checkout
- git-c-b ...Create a new branch and checkout
- git-p ...Pull
- git-set ...Interactively perform add/commit/push. Please correct me if my English sounds awkward.
Troubleshooting
-
.bashrc is not being loaded
- Check if .bash_profile is loading .bashrc
- cf.
[bash] Things to check when .bashrc is not loaded after starting the terminal
- cf.
- Check if .bash_profile is loading .bashrc
-
The backspace (delete) key is converting to strange characters after executing the alias command
- Keyboard is US layout → remains as ^H in .bashrc
- JIS → change ^H to ^?
Thoughts
- My development efficiency has improved just a little!
- How do people who use git usually do it? Do they create aliases?
Postscript
I forgot there is a command called git config for setting git aliases.
Set aliases for commonly used git commands to improve development efficiency