Skip to content

Instantly share code, notes, and snippets.

@inspector71
Last active June 13, 2023 03:14
Show Gist options
  • Save inspector71/780d47d0b429c2468ea6004021a8e0ee to your computer and use it in GitHub Desktop.
Save inspector71/780d47d0b429c2468ea6004021a8e0ee to your computer and use it in GitHub Desktop.
# Git basics
## List Git branches
alias b="git branch --list; git remote show origin"
alias d='git diff '
alias g='git status '
alias ga='git add --all '
alias gc='git commit '
alias gco='git checkout '
## Git amend last commit message
alias gcatext='git commit --amend '
## Git add a file to the last commit
alias gcafile='git commit --amend --no-edit '
alias gf='git fetch '
alias gg='git grep '
alias gl='git log --decorate --name-only '
alias gundo='git checkout -- '
alias gunadd='git reset HEAD '
alias pull='git pull '
alias push='git push '
# Git history by filename
alias filestory="git diff --name-only "
# Git history by commit, file, last 2 years
alias filestory730="git log --name-status --oneline --since='2 years ago'"
# Git history by commit, file
alias gistory='git log --name-status --oneline '
# Git log and diff, colourful
alias gitstory="git log -p --pretty='tformat:%n%C(yellow)%h%C(reset) %C(bold ul white)%an%C(reset) [%C(cyan)%ar%C(reset)] %C(reverse dim cyan)%s%n%C(magenta)======'"
# Git Hash Author Relative Date Log
alias hardl="git log --pretty='tformat:%C(yellow)%h%C(reset) %C(bold ul white)%an%C(reset) [%C(cyan)%ar%C(reset)] %C(reverse dim cyan)%s'"
# Git push new local branch to remote, creating push/pull association (`set up to track`) between the two
alias setupremote="git push -u origin "
# Git switch branch
alias swb="git checkout "
alias gitop='cd ./`git rev-parse --show-cdup` '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment