GitHub Flow Like a Pro with These 13 Git Aliases
haacked.com
haacked.com
summary = !git log $(git log -1 --merges --pretty=format:%H)..HEAD --oneline
This prints the log summaries on one line up to the last merge commit. If you are working on a feature/topic branch (and you collaborators do too), this will just print out the commits you have add for the feature. I often use this to go back and rebase fixups or suggestions from a code review.
git log --all --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
... you get visual branching and merging, branch names, useful dates, authors, etc.
log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
That way you're not mixing it up in your head, and wipes should be rare enough that you don't build muscle memory.
clean=!git add -A && git commit -m "TMP: Save before clean reset" && git reset HEAD~1 --hardI think it's a better idea to use git add -p to review your changes before commiting them.
If you combine that with a checkout (co) alias which saves the current branch and checks the latest commit message of the destination branch and 'reset HEAD~1 --mixed's when it was 'SAVEPOINT' and functionally you have regular git that allows you to move around between branches without committing first.
eject=!git reset --hard && git checkout master && git rebase --abort
Although I prefer multiple commands to be a bash or as below a fish alias:
function giteject
git reset --hard
and git checkout master
and git rebase --abort
endAlthough when I went to share it in slack, the preview text was "You've been Haacked and you like it". I personally find that a tasteless slogan; but more-so it should be the title of the post I linked, not the site title.
I have a few aliases in my .bashrc file that I use:
alias git-branch-list='for k in `git branch|sed s/^..//`;do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" "$k"`\\t"$k";done|sort'
alias c="git commit -m '"
alias s='git status'
alias a='git add'
I use the first one to hop around branches and see when the branch was last updated. The others are just because I am super lazy. But reading the post I am moved to be even lazier!
You are right though, his title tags on his blog aren't really descriptive... Which is uncommon for a "reasonable" popular blog (Haack is almost as known as Hanselman in the .Net world, untill he left Microsoft for Github a couple of years ago - he's been more quiet since then :-) )
I added an issue for his site here: https://github.com/Haacked/haacked.com/issues/178 (gotta love developers)
I'd be interested to hearing why you feel that way. Perhaps there's an angle I hadn't considered.
It's supposed to be tongue in cheek. My last name is pronounced "Hack". Being hacked is usually a bad thing. But being "Haacked" is something you would like. At least, that's my goal! :)