1. 7
    1. 12

      I’d recommend defining the aliases in ~/.gitconfig. This makes them shell-agnostic and avoids naming collisions.

      Here are a few examples from my ~/.gitconfig:

      	a = add
      	b = branch
      	c = commit
    2. 7

      There is literally no way I could remember even 10% of these… I have one alias, gst for git status because I type it a lot and the word status is annoying to type (mostly left hand). I’d be curious to know how many aliases people actually remember to use.

      1. 2

        I pretty much exclusively use git with aliases, all of which are g followed by two letters: https://bin.sebsite.pw/082h

        It definitely depends on how used to git without aliases you are. I started using aliases from the very beginning so these are all part of my muscle memory, but it’s definitely not something I’d recommend to someone who’s already comfortable using git. Or at the very least, the aliases should be created incrementally for commands that you find yourself using frequently, not memorized all at once.

    3. 6

      Feels like there is some lesson about tab completion or better terminal UIs here.

      1. 1

        This post made me look up how to import history into atuin (tldr - zsh history is just a flat file of commands with no additional metadata which can be found at $HISTFILE). I would rather have atuin fuzzy find the full, verbose (readable) command rather than attempt to remember the alias.

      2. 1

        Magit is definitely a better TUI/GUI.

    4. 3

      The only alias I use with git is a shell alias for gpo which is git push origin HEAD

      type everything else out, even status

      1. 2

        Similar. I use fish, which makes it so easy to repeat a command from history that shortening it is pointless: I type “push↑” (that’s an up arrow), and fish finds it from history in its glorious canonical form, which is how I use it:

        git push --force-with-lease origin HEAD~N:refs/heads/(whatever)

        Here, I do use the shorthand whatever for git rev-parse --abbrev-ref HEAD, or whatever branch I’m on. The point is not so much to shorten, but to normalize history, so I can repeat it.

    5. 3

      I got so many aliases, but the ones I probably use the most are these:

      dft = difftool
      lol = log --oneline --graph --all
      l = log --graph --all
      branches = !git for-each-ref --color=always --sort=-committerdate --format='%(color:yellow)%(refname:short)%09%(color:green)%(authorname)%09%(color:blue)%(committerdate:relative)%09%(color:red)%(objectname:short)%09%(color:magenta)%(upstream:track)%09%(color:white)%(contents:subject)%(color:reset)' refs/heads refs/remotes|column -t -s $'\t'
      1. 2

        To me, my most used are:

        • gsd='git status -s | cut -d " " -f 3 | xargs -I {} git stash push {} -m "{}"'

        This takes everything that is currently staged or not and pushes into the stash with an appropriate message. What I’ve found annoying about stashing is that it by default uses the latest commit as the stash title instead of the far more descriptive file name.

        • gd='git diff --color-words'

        I’ve found this to be a far better diffing experience than the regular diff as when a single word changes within a line it shows it much more clearly. Same for staged changes: gds='git diff --staged --color-words'

        • gdog="git log --pretty=format:'%C(auto)%h %C(blue) %<|(20) %aI %C(auto) %d %s' --graph --all --decorate"

        A very clean history with just the short SHA, date, and message with the reference.

        function diff_stash() {
          # $1 - item number from 'git stash list'
          local item="$1"
          git stash show -p stash@{"$item"}

        This allows me to show what is in the stash based on the index.

        function gdogtag() {
          git log \
            --pretty=format:'%C(auto)%h %C(blue) %<|(20) %aI %C(auto) %d %s' \
            --graph \
            --decorate \
            "$(test -d "${PWD}/.git" && git describe --tags --abbrev=0 @^)..@"

        Shows me the commits between the current state and the previous tag.