Anyone have some gems for git that should be added to every base install? Some cool commands that you cant live without, thus add them to your .gitconfig [alias]'s
ps: seen some questions like this about other things, hope its the best place
Anyone have some gems for git that should be added to every base install? Some cool commands that you cant live without, thus add them to your .gitconfig [alias]'s
ps: seen some questions like this about other things, hope its the best place
 
    
    One I've recently discovered that I quite like is actually in the contrib dir of git, so it's easy to get: It's called git new-workdir
It allows you to create a second working directory for a repository, without duplicating the entire repository. This allows you to work in two separate branches simultaneously, which has come in quite handy for me.
 
    
    some of the ones i got (off random sites, don't remember where)
for a pretty treeish view of all the commits:
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
get the last commiter
whois = "!sh -c 'git log -i -1 --pretty=\"format:%an <%ae>\n\" --author=\"$1\"' -"
show the last commit
whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short
 
    
    This will give you la and lc which shows you a oneline log strictly ordered by 'author' or 'commit' date respectively. The 'u' in the pretty specifications relates to "unix timestamp". The unix timestamp is only included for sorting and stripped later. An ISO version of the time remains.
alias.la=! log () { git log --pretty=lau $1 | sort -rn | cut -d " " -f 2- | less ; } ; log  
alias.lc=! log () { git log --pretty=lcu $1 | sort -rn | cut -d " " -f 2- | less ; } ; log
pretty.lau=format:%at %C(dim yellow)%h %C(cyan)%ai%Cgreen%d %Creset%s
pretty.lcu=format:%ct %C(dim yellow)%h %C(cyan)%ci%Cgreen%d %Creset%s
Usage is git la <commit specifiers>, so could be git la or git la branch or git la C1..C2. Note however, that the .. still acts in the usual log way. Sorting is only post-processing.
And here is another one:
> cat ~/bin/git-advance 
#!/bin/bash
C="`git log --first-parent --format=%H ..$1 -- | tail -1`"
if [ -z "$C" ]; then
    echo "Could not determine next commit"
    exit 1
fi
git checkout "$C"
And then of course, alias.advance=! git-advance. Usage is git advance <future-commit> and will checkout the next commit from current HEAD towards the given <future-commit>. This will result in a detached HEAD but I find it handy for propagating commits from git to another VCS manually. No guarantees, didn't try it on complicated histories yet.
Here is something experimental for missed renames in merge conflicts:
