Last active
August 27, 2023 11:16
-
-
Save stephenchew/e24bd74a6d992a9c44b42ed5322c82b8 to your computer and use it in GitHub Desktop.
Handy shell aliases for Git.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # OS common | |
| alias l='ls -l --color=auto' | |
| alias ll='ls -al --color=auto' | |
| # Git | |
| alias gc='git commit' | |
| alias gcm='git commit -m' | |
| alias gco='git checkout' | |
| alias gsw='git switch' | |
| alias gsm='BRANCH=$(gdef) && git switch $BRANCH' | |
| alias gsn='git switch main' | |
| alias gsml='gsm && git pull' | |
| alias gsnl='git switch main && git pull' | |
| alias gsc='git switch -c' | |
| alias gscf='git switch -C' | |
| alias gs='git status' | |
| alias gb='git branch -v' | |
| alias gl='git pull' | |
| alias gp='git push' | |
| alias gpom='git push -u origin master' | |
| alias gpon='git push -u origin main' | |
| alias gf='git fetch' | |
| alias gfpa='git fetch --prune --all' | |
| alias gfm='git fetch origin master:master' | |
| alias gfn='git fetch origin main:main' | |
| alias gfh='BRANCH=$(gdef) && git fetch origin $BRANCH:$BRANCH' | |
| alias glog='git log --pretty=oneline --graph' | |
| alias gdlocal="git branch -v | grep '\[gone\]' | awk '{print \$1}' | xargs git branch -D" | |
| alias gr1="git reset HEAD~1" | |
| alias gr2="git reset HEAD~2" | |
| alias gr3="git reset HEAD~3" | |
| alias gbi="git rebase -i" | |
| alias gsync='BRANCH=$(gdef) && git switch $BRANCH && gl && gfpa && gdlocal' | |
| alias gdef="git remote show origin | sed -n '/HEAD branch/s/.*: //p'" | |
| alias gph="gfpa && gfh" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this line to
.bashrcfor initialisation.