Live data from Hacker News

Aliasing Your Git Commands for Maximum Developer Efficiency

tutorialedge.net

21–30 of 31 posts

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#21
Somehow my brain doesn't work like that (short aliases).

I usually use long form commands and parameters. I use ZShell history + FZF to get at commands with minimal keystrokes.

Don't really have to remember anything. Some vague snippets will narrow it down really fast.

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#22
post #17

Earlier quoted context omitted.

I would guess a list this long is self defeating. You wouldn't remember the ones you don't use often but would have a better chance remembering the full command because the language of the command is more intuitive.

Memory is pretty weird with these - I find that my hands do most of the remembering, and my mind doesn't have to do much work. It must be a very individual thing - hope everyone is doing what works for them. And you're right that there's always a safe fallback to default commands. I will admit that seeing the list in its entirety when posting it, I was surprised at its length, but I estimate I use at least 50% of the…

> It must be a very individual thing

I suppose that is true because I can't remember more than 3 of my shell git aliases but I'm the most basic git user you can get and I don't use them for work.

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#24
post #8

Great example of premature optimization. Save seconds per day typing "gc" instead of "git commit"

No it's called nesting, and it is the most holy of practices.

Your axe doesnt need to be extra sharp so you can cut one extra tree in a day, it needs to be extra sharp so it feels good to chop down trees.

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#25
One time I argued with my junior developer for like 30 minutes convinced that `git cp` was a built in command and not an alias. Turns out I had been carrying that alias through 4 different dot files managers and had completely forgotten that I wrote it.

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#26

If you're interested, Oh my zsh already has git aliases and much more for dev productivity. It also has a really large number of supported plugins. https://github.com/ohmyzsh/ohmyzsh?tab=readme-ov-file https://kapeli.com/cheat_sheets/Oh-My-Zsh_Git.docset/Content...

oh-my-zsh also checks for updates.

Batteries included can be nice.

When your batteries start to run their own webservers and phone home, someone mistook convenience for batteries.

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#27
post #26

If you're interested, Oh my zsh already has git aliases and much more for dev productivity. It also has a really large number of supported plugins. https://github.com/ohmyzsh/ohmyzsh?tab=readme-ov-file https://kapeli.com/cheat_sheets/Oh-My-Zsh_Git.docset/Content...

oh-my-zsh also checks for updates. Batteries included can be nice. When your batteries start to run their own webservers and phone home, someone mistook convenience for batteries.

Updates can be easily disabled: https://github.com/ohmyzsh/ohmyzsh?tab=readme-ov-file#gettin...

I'm pretty sure that omz is not running their own webserver (correct me if I'm wrong here). It is just doing a git pull to update. [1]

[1]: https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/upgrade...

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#28
post #8

Great example of premature optimization. Save seconds per day typing "gc" instead of "git commit"

how is it a premature optimization? what makes it premature? are you waiting for the thing that comes after git and then you're going to optimize? you don't have to add these aliases if you don't want, but git, and it's usage is fairly mature by this point.

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#29
post #17

Earlier quoted context omitted.

Same thing - I put them in my shell. Here is the list I use: alias ga="git add" alias gaw="git add -A && git diff --cached -w | git apply --cached -R" alias gb="git branch" alias gbl="git branch -l" alias gbD="git branch -D" alias gbu="git branch -u" alias gc="git commit" alias gca="git commit -a" alias gcaa="git commit -a --amend" alias gcam="git commit -a -m" alias gce="git commit -e" alias gcfu="git commit --fixup…

I would guess a list this long is self defeating. You wouldn't remember the ones you don't use often but would have a better chance remembering the full command because the language of the command is more intuitive.

I recall seeing a omz (IIRC) plugin that reminds you of aliases that match the commands that you just ran. I had this turned on, but it got too annoying :)

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#30

I have several git alias that I live by: ga = git add -A gc = git commit gcm = git commit -m gp = git push All of these are defined in my zshrc rather than doing it through git config.

Same thing - I put them in my shell. Here is the list I use: alias ga="git add" alias gaw="git add -A && git diff --cached -w | git apply --cached -R" alias gb="git branch" alias gbl="git branch -l" alias gbD="git branch -D" alias gbu="git branch -u" alias gc="git commit" alias gca="git commit -a" alias gcaa="git commit -a --amend" alias gcam="git commit -a -m" alias gce="git commit -e" alias gcfu="git commit --fixup…

I do similarly but my favorite git log ("gl") variant (in a bash script rather than an alias) is:

set -eux

git log --notes --decorate=full --source --stat --summary -C -M --pretty=fuller $*|less

...so that I can see if there was any revision to a commit after it was first committed, which files were changed and how much, and pass extra parameters if needed.

Post reply on HN