Live data from Hacker News

Aliasing Your Git Commands for Maximum Developer Efficiency

tutorialedge.net

11–20 of 31 posts

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#13
post #9

Eh. I've only ever aliased "git status -s | awk '$1 == "M" { print $2 }' | xargs -t git add" as "git_add_all": branch switching works well enough in VSCode, "git diff" shows you your commit preview perfectly fine, and shortening "git push" and "git commit" never really felt like a pressing concern. Actually, no, there is also "git_show_branch" because every time I needed that in the shell, I could never remember the…

Is that different then git add -u

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#14
I like to keep it pretty simple for git aliases, all defined in my shell alias set:

    ```
    s="git status"
    d="git diff"
    c="git diff --cached"
    ```
I have one other, `rb`, which uses a lot of intermediate work to print all the recent branches I've committed to with nice conditional formatting.

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#17

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 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.

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#19
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.

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 these often!

Looking at the other posts in the thread, it looks like this set of aliases is very similar (maybe I should switch to cut some fat out of my dotfiles): https://kapeli.com/cheat_sheets/Oh-My-Zsh_Git.docset/Content...

Re: Aliasing Your Git Commands for Maximum Developer Efficiency

#20
post #4

One of my favorites is gsw=“git switch -“. It switches back to whatever branch you were last on.

I learned about git switch through comments for this article on reddit. It's definitely something I'm actively trying to adopt at the moment over my old workflow but it's soo hard to overcome years of muscle memory
Post reply on HN