Live data from Hacker News

Ask HN: What are some Git aliases you setup that save you time?

news.ycombinator.com

31–35 of 35 posts

Re: Ask HN: What are some Git aliases you setup that save you time?

#31

Earlier quoted context omitted.

Yoy dirty, I hope Mr Gandalf pipeline, say the words!

You shall not pass! But I'm a demon and I'm taking my commit with me to the depths of hell

Haha I'm just kidding, I also have similar alias on my toolbelt too, it's for emergencies purposes, I swear!

Re: Ask HN: What are some Git aliases you setup that save you time?

#32

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 = !…

Unless 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)

Re: Ask HN: What are some Git aliases you setup that save you time?

#33
post #17

resync = git checkout master && git pull && git checkout - && git pull --rebase master asquash = git rebase -i master --autosquash abs = git absorb -b HEAD~20 everything else is handled by vim-fugitive

What is ‘absorb’? Never seen before. What is it for?

https://github.com/tummychow/git-absorb

Re: Ask HN: What are some Git aliases you setup that save you time?

#34
used this post from Jonathan Suh, it's fairly comprehensive. I think I use most except several that I'm worried I might accidentally type in (in a hurry or whatnot) and do something too destructive: https://jonsuh.com/blog/git-command-line-shortcuts/

Re: Ask HN: What are some Git aliases you setup that save you time?

#35

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 = !…

Unless 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)

Thank you I didn't know about this. Your version is a bit more compact.
Post reply on HN