My Git Aliases Categorized by Usage

These are the aliases I use in my .gitconfig file.

Most Used

[alias]

# status of commit
st = status -sb

# add, commit, stage your changes
acm = !git add . && git commit -m

# add, commit, stage, and push changes to origin
acmp …


This content originally appeared on DEV Community and was authored by DEV Community

These are the aliases I use in my .gitconfig file.

Most Used

[alias]

# status of commit
st = status -sb

# add, commit, stage your changes
acm = !git add . && git commit -m

# add, commit, stage, and push changes to origin
acmp = "!f() { git acm \"$@\" && git p; }; f"

# commit with message
cm = commit -m

# get branch
br = branch

# delete a branch only if it has been merged
bd = branch -d 

# force delete a branch
bDf = branch -D 

# checkout a new not yet existing branch
cob = checkout -b

# push changes to a remote
p = push

# fetch from repo and prune any remote-tracking refss that no longer exist on remote
f = fetch -p

Less Commonly Used


# edit this config file
edit-config = config --global -e 

# show aliases
aliases = config --get-regexp alias 

# stash list
sl = stash list

# stash work (along with untracked files) with message
ss = stash save -u

# get a stash (ie. stash@{2})
sp = stash pop

# get most recent stash
sprecent = stash pop stash@{0} 

# logging
plog = log --graph --pretty='format:%C(red)%d%C(reset) %C(yellow)%h%C(reset) %ar %C(green)%aN%C(reset) %s'

Never Really Used, but Exist


# remove all branches merged into the branch I'm on
bdm = "!git branch --merged | grep -v '*' | xargs -n 1 git branch -d" 

# checkout a branch
co = checkout

# push changes to master
pom = push origin master 

# tag a version
t = tag

# list contributors
rank = shortlog -sn --no-merges

# logging
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

tlog = log --stat --since='1 Day Ago' --graph --pretty=oneline --abbrev-commit --date=relative

# View unpushed commits
unpushed = !GIT_CURRENT_BRANCH=$(git name-rev --name-only HEAD) && git log origin/$GIT_CURRENT_BRANCH..$GIT_CURRENT_BRANCH --oneline

# View unmerged branches, except for those beginning with "archive/" and "staging"
unmerged-D = !git branch --no-merged develop | grep -Ev \"(archive/|staging)\"
unmerged-M = !git branch --no-merged master | grep -Ev \"(archive/|staging)\"

# View which branches need to be merged, except for those beginning with "archive/" and "staging"
active-merged-D = !git branch --merged develop | grep -Ev \"(archive/|staging)\"

Comment below with your favorite git aliases!

Thanks for reading, and Happy Coding!
Brian


This content originally appeared on DEV Community and was authored by DEV Community


Print Share Comment Cite Upload Translate Updates
APA

DEV Community | Sciencx (2022-03-10T06:32:00+00:00) My Git Aliases Categorized by Usage. Retrieved from https://www.scien.cx/2022/03/10/my-git-aliases-categorized-by-usage/

MLA
" » My Git Aliases Categorized by Usage." DEV Community | Sciencx - Thursday March 10, 2022, https://www.scien.cx/2022/03/10/my-git-aliases-categorized-by-usage/
HARVARD
DEV Community | Sciencx Thursday March 10, 2022 » My Git Aliases Categorized by Usage., viewed ,<https://www.scien.cx/2022/03/10/my-git-aliases-categorized-by-usage/>
VANCOUVER
DEV Community | Sciencx - » My Git Aliases Categorized by Usage. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/10/my-git-aliases-categorized-by-usage/
CHICAGO
" » My Git Aliases Categorized by Usage." DEV Community | Sciencx - Accessed . https://www.scien.cx/2022/03/10/my-git-aliases-categorized-by-usage/
IEEE
" » My Git Aliases Categorized by Usage." DEV Community | Sciencx [Online]. Available: https://www.scien.cx/2022/03/10/my-git-aliases-categorized-by-usage/. [Accessed: ]
rf:citation
» My Git Aliases Categorized by Usage | DEV Community | Sciencx | https://www.scien.cx/2022/03/10/my-git-aliases-categorized-by-usage/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.