I'd always make one for my work dev folder so I could quickly switch to it as soon as I restarted my terminal. I'd always make it just a 2 letter abbreviation. For example, my last one was an alias "s6" to take me the the correct dev folder.
These all are included in zsh git aliases but listed these I'm using on regular basis.
I also have a function that checks out master, pulls it, runs DB migrations and so on.
For longer ones like `g reset --soft HEAD~1` where I cba setting up alias, I just ctrl+r and fetch them with fzf or zsh autosuggestions - probably same amount of keystrokes as typing out alias
I don't use aliases, and I don't feel line I am losing time, like at all. Well I need to touch my hardware key when I push, which takes half a second...
e.g. committing the staged changes would involve just "cc". Rewording the last commit is "cw", amending is "ce", and fixing up earlier commits is "cf".
Checking out a new branch is "bc", whereas creating a new branch is "bn".
Fetching to the default origin is "ff", likewise pushing is "pp".
But aside from the keymap being very terse, it's also highly discoverable. You're shown all the git commands, and before invoking a command, all the options for that command.
I feel like every other commit I forget something, so a `git j<tab>` (I don't have any other aliases that what with j) puts my last minute fix where it belongs. Also nice during interactive rebases.
used this post from Jonathan Suh, it's fairly comprehensive. I think I use most except several that I'm worried I might accidentally type in (in a hurry or whatnot) and do something too destructive: https://jonsuh.com/blog/git-command-line-shortcuts/
34 comments
[ 1.8 ms ] story [ 186 ms ] threadgc - commit
gc! - amend
gcm - checkout master
gco - checkout
gcb - checkout new branch
Rebase:
grb
grbc - continue
grba - abort
Cherry pick:
gcp
gcpc - continue
gcpa - abort
These all are included in zsh git aliases but listed these I'm using on regular basis.
I also have a function that checks out master, pulls it, runs DB migrations and so on.
For longer ones like `g reset --soft HEAD~1` where I cba setting up alias, I just ctrl+r and fetch them with fzf or zsh autosuggestions - probably same amount of keystrokes as typing out alias
https://jdsalaro.com/note/wrist-friendly-git-shortcuts
I decided against git aliases in favour of shell aliases, but people might still find them interesting.
For me, and my wrists, gs and gf have been game-changing.
e.g. committing the staged changes would involve just "cc". Rewording the last commit is "cw", amending is "ce", and fixing up earlier commits is "cf".
Checking out a new branch is "bc", whereas creating a new branch is "bn".
Fetching to the default origin is "ff", likewise pushing is "pp".
But aside from the keymap being very terse, it's also highly discoverable. You're shown all the git commands, and before invoking a command, all the options for that command.
asquash = git rebase -i master --autosquash
abs = git absorb -b HEAD~20
everything else is handled by vim-fugitive
git checkout -
returns you to the previous branch
(same for cd, "cd -" returns you to previous dir)
[alias] g = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
https://gitlab.com/halcanary/config/-/blob/master/git_config...
[2] git-push-set-upstream - Push current branch to remote
And plenty more…
[1] https://github.com/benwinding/dotfiles/blob/master/bin/githu...
[2] https://github.com/benwinding/dotfiles/blob/2239e56df2a49818...
```
function w
end```
Lifesaver and timesaver.
I have one called `b` that creates a new branch and commits.
One called `poop` that pushes the current branch to GitHub and create a PR.
etc etc
unstage = git restore --staged