DEV Community

Discussion on: Moving from beginner to (slightly more) advanced git with aliases.

Collapse
 
lt0mm profile image
Tom • Edited

For that reason I use shell alias which shows status after adding something


a = "!f() { git add ${1-.} $2 $3 $4 && git status; }; f"

and also I will put just several aliases which I find very useful, unfortunately some of them won't work on windows

shows aliases it is very convenient for seldom used aliases and when you just have added some new (won't work on windows)

aliases = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort  | grep -E --color=auto ^[a-z-]+

I really like short form of status


s = status -s

and because of that st is full form


st = status

log can be in your custom format, mine is a little bit complicated because of colors, it shows hash, date, time, branch, author and message in one line

l = log  --format='%h %Cgreen%ad%Creset %C(bold blue)%an%Creset %Cred%d%Creset %s ' --date=format:'%d.%m.%Y %H:%M:%S

log with modified files list


lf = "!git l --name-status"

Get the current branch name (used in other aliases)


branch-name = rev-parse --abbrev-ref HEAD

Push the current branch to the remote "origin", and set it to track the upstream branch


publish = "!git push -u origin $(git branch-name)"

PS sorry for such big comment
PS2 and I've found one of my sources, there are a lot of useful aliases there, you can chose something which is suited you gist.github.com/robmiller/6018582