Live data from Hacker News

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

news.ycombinator.com

21–30 of 35 posts

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

#21
post #14

[alias] justdoit = commit --amend --no-edit I feel like every other commit I forget something, so a `git j ` (I don't have any other aliases that what with j) puts my last minute fix where it belongs. Also nice during interactive rebases.

I use this a lot but I have a version with --no-verify to skip hooks too.

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

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

#25
[1] github-branch-open-pr - Open current branch as new PR in browser

[2] git-push-set-upstream - Push current branch to remote

And plenty more…

[1] https://github.com/benwinding/dotfiles/blob/master/bin/githu...

[2] https://github.com/benwinding/dotfiles/blob/2239e56df2a49818...

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

#26
I have a bunch, but one of my favorite is a fish shell function that writes wip commits:

```

function w

    #set --local staged (gs | cut -c1 | ag -v "\?" | string collect | string trim)
    set --local staged (git status -s | grep "^[MADRCU]" | string collect | string trim)
    if test -n "$staged"
        #echo "something staged"
    else
        #echo "nothing staged"
        git add .
    end

    if not string length -q -- "$argv"
        gc -m 'WIP' -n
    else
        gc -m "$argv" -n
    end
end

```

Lifesaver and timesaver.

I have one called `b` that creates a new branch and commits.

One called `poop` that pushes the current branch to GitHub and create a PR.

etc etc

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

#28

Earlier quoted context omitted.

I use this a lot but I have a version with --no-verify to skip hooks too.

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

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

#29
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)
Post reply on HN