Lurker News

Comments (229) 38 threads

Show all comments

Showing thread 10 of 38

stockkid5 replies#
Personally I have been typing all git commands manually into the terminal and never felt a need for GUIs or tools such as this.

There are a number of git shortcuts defined in my zsh aliases [0]. It goes like:

  # Git aliases
  alias g='git'
  alias ga='git add'
  alias ghb='git browse' # hub
  alias ghpr='git pull-request' # hub
  alias gp='git push'
  alias gpoh='git push origin HEAD'
  ...

Using these aliases, we rarely have to type more than 3-4 characters for a git command. Savings and efficiency not only add up over years of using git, but also accelerate as you become more proficient in using your own aliases that fit your special needs.

[0] - https://github.com/sungwoncho/dotfiles/blob/master/zsh/alias...

mehrdadn#
Also simple but very handy:

  [alias]
  	amend = commit --amend --no-edit
  	ls = ls-tree --name-only --full-name HEAD
  	tree = log --graph --decorate --oneline --all
  	commit-date = "!gitcommitdate() { (export GIT_COMMITTER_DATE=\"$1\" && git commit --date=\"‎${GIT_COMMITTER_DATE}\" \"${@:2}\"); } && gitcommitdate"
There's also a whole boatload of commands in git-extras for those interested: https://github.com/tj/git-extras/blob/master/Commands.md
mlthoughts20181 reply#
I personally prefer to use a combination of a foot pedal and eye tracking cameras to enter a Reed-Solomon code of taps and blinks uniquely mapping to git commands.
roryisok1 reply#
I think I've met you at a conference. Were you the guy blinking U-S-E-V-I-M on Morse code during conversations

Continue this thread — 1 reply

jordigh2 replies#
With Mercurial, I like that all commands can be abbreviated to their shortest unique prefix, plus some built-in aliases. So I type a lot of `hg up`, `hg pus`, `hg ci`, `hg pul`, `hg bo`, and so forth. Most of these are almost the same length as your aliases.

Whenever I have to touch git and `git co` doesn't work, I think, okay, fine, we'll go through the full dress rehearsal; `git checkout` it is.

h1d#
Hard to believe how git doesn't have them by default.
muxator#
Plus, actually sane command names, and super powerful functionalities (for example, answering to another comment, you always could "hg blame (annotate)" an arbitrary version of a file without having to check it out first)!
__blockcipher__#
I've been playing around with hub recently, but ended up commenting out the "source hub alias" line because a) since I use aliases, you might as well be explicit, b) I'm tired of having to pipe my aliases to `sed 's/hub/git/g'` when I do `which my_git_alias` to send to other people, and c) I don't want to support github conflating the two when it's not that hard to remember which does what even if you don't use aliases.

Another tip, I only occasionally need git autocompletion withh aliases, but in zsh you can do something like this:

  # Enable zsh git completion for our aliases.
  # See     https://github.com/mislav/dotfiles/blob/d82e79b8a500891a02ab28171974d68be7a35e12/shrc/git.sh
  if [ -n "$ZSH_VERSION" ]; then
    compdef _git g=git
    compdef _git gc=git-commit
    compdef _git gco=git-checkout
    compdef _git gd=git-diff
    compdef _git gb=git-branch
    compdef _git gst=git-status
    compdef _git gp=git-push
    compdef _git gd=git-diff
  fi
And obviously bash has an equivalent.