3 ms·
Here are a couple that I use a lot. There's probably a shorter way to write them: # show the last 10 branches I used lb = !git reflog show --pretty=format:
by fantapop 3y ago
Here are a couple that I use a lot. There's probably a shorter way to write them:
# show the last 10 branches I used
lb = !git reflog show --pretty=format:'%gs ~ %gd' --date=relative | grep 'checkout:' | grep -oE '[^ ]+ ~ .*' | awk -F~ '!seen[$1]++' | head -n 10 | awk -F' ~ HEAD@{' '{printf(\" \\033[33m%s: \\033[37m %s\\033[0m\\n\", substr($2, 1, length($2)-1), $1)}'
# checkout the previous branch I was using
cop = !git checkout --recurse-submodules $(git reflog show --pretty=format:'%gs ~ %gd' --date=relative | grep 'checkout:' | grep -oE '[^ ]+ ~ .*' | awk -F~ '!seen[$1]++' | head -n 10 | grep -v $(git branch --show-current) | head -1 | cut -d' ' -f1)
- MattBearman 3y agoUnless I’m misunderstanding you can checkout your previous branch with git checkout - (The same way you can use ‘cd -‘ to change to your previous directory)
- fantapop 3y agoThank you I didn't know about this. Your version is a bit more compact.