1. 21
  1.  

  2. 9
    [alias]
            tags = tag -l
            branches = branch -a
            remotes = remote -v
    
    1. 3

      Thanks! I recall those (or equivalents) are built into mercurial. Anybody know any other band-aids over git’s cli?

      I should mention, to the git teams credit, git has been slowly becoming more sane and consistent about flags and behaviours

      1. 3
        [alias]
            root = rev-parse --show-toplevel
            discard-merge = reset --hard HEAD
            current-branch = rev-parse --abbrev-ref HEAD
            addremove = !git add . && git add -u
        
        1. 2

          Of course you’d comment on it. During the brief project where I did use mercurial, your blog’s posts on mercurial got a lot of reading.

          Thanks!

    2. 4

      staged = diff --cached

      You can actually use --staged instead of --cached, which is much easier to remember. (You might still want to keep the alias, of course.)

      1. 2

        I have to wonder why unstage isn’t defined as unstage = reset HEAD. That would save keystrokes and would mean you could just type git unstage FILE.txt. Is there a situation where you want to unstage to something other than HEAD?

        1. 3

          HEAD is actually the default <tree-ish>/<commit> argument, so git reset FILE.txt and git reset HEAD FILE.txt should produce the same results.

          To your question, there might be a situation in which one might want to unstage something other than HEAD, but I’ve never encountered it.

          1. 2

            (misclick, sorry)

          2. 1

            Here are some of my aliases that seem to fit with the spirit of the article:

            # List all tags
            tags = tag -l -n1
            
            # List tags that don't look like version numbers ("other tags"). (My
            # main work repo has dozens of version-number tags and it's handy to
            # be able to exclude them from the output.)
            otags = !git tags | grep -v "^v[0-9]"
            
            # Rewrite the last commit to include the currently-staged changes
            amend = commit --amend -C HEAD --reset-author
            
            # Show the root directory of this repo. Useful in combination with
            #   alias cdr='cd $(git root)'
            # in my zshrc.
            root = rev-parse --show-toplevel
            
            1. 1

              Here are some of mine:

              branches = branch -va
              graph = log --graph --abbrev-commit --decorate
              outgoing = cherry -v
              amend = commit --amend --no-edit
              last = log -n 1
              yesterday = log --branches --since=1.days.ago --author=\"<my name>\" --format=\"%s\" --no-merges
              purify = clean -fdx
              

              The others I have are shortcuts for common actions, like co for checkout at cm for commit.