Live data from Hacker News

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

news.ycombinator.com

11–20 of 35 posts

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

#11
Emacs' Magit is an excellent interface for git.

e.g. committing the staged changes would involve just "cc". Rewording the last commit is "cw", amending is "ce", and fixing up earlier commits is "cf".

Checking out a new branch is "bc", whereas creating a new branch is "bn".

Fetching to the default origin is "ff", likewise pushing is "pp".

But aside from the keymap being very terse, it's also highly discoverable. You're shown all the git commands, and before invoking a command, all the options for that command.

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

#12

For anyone new to aliases, you can add them with: alias my_alias="command" Add it to your ~/.bash_profile or ~/.zprofile so it's ready whenever you are. Check out this page for more info: https://linuxize.com/post/how-to-create-bash-aliases/

    [alias]
      br = branch
      co = checkout
      d = diff
      dc = diff --cached
      ec = config --global -e
      latest = log -1 HEAD
      please = push --force-with-lease
      st = status
Aliases for git can be added to ~/.gitconfig

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

#13

    # Prettier logs:
    lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
    ll = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative -20
    l1 = log --pretty=oneline --abbrev-commit --decorate

    # Show (all) (cached) diffs in Beyond Compare:
    da = !sh diffall.sh
    dac = !sh diffall.sh --cached
    dt = difftool
    dtc = difftool --cached

    # Short status:
    st = status -sb
    ss = "!showci () { rev=${1:-HEAD}; git da $rev~1 $rev; }; showci $1"

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

#16
post #13

# Prettier logs: lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative ll = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative -20 l1 = log --pretty=oneline --abbrev-commit --decorate # Show (all) (cached) diffs in Beyond Compare: da = !sh diffall.sh dac = !sh diffall.sh --cach…

I have a similar git lg. It’s my most used command

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

#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?

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

#20
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.
Post reply on HN