4 ms·
Don’t forget a bunch of useful git aliases alias gcm=git commit -m alias gaugcm = git add -u && gcm
by jerpint 3y ago
Don’t forget a bunch of useful git aliases
alias gcm=git commit -m
alias gaugcm = git add -u && gcm
- dfinninger 3y agoMy favorite: alias gfp=“git commit --amend --no-edit && git push --force-with-lease” For those “whoops, for got to add $x file” moments or typos
- ithkuil 3y agoI have basically that set up as gitconfig alias "git amen"
- alhirzel 3y agoHere are the ones from my shell, accrued into muscle memory and my zshenv over the years: 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" alias gcm="git commit -m" alias gco="git checkout" alias gcob="git checkout -b" alias gcoB="git checkout -B" alias gcp="git cherry-pick" alias gcpc="git cherry-pick --continue" alias gd="git diff" alias gd^="git diff HEAD^ HEAD" alias gds="git diff --staged" alias gl="git lg" # TODO - make these options defaults for "git log" itself alias glg="git log --graph --decorate --all" # TODO - make these options defaults for "git log" itself alias gdc="git diff --cached" alias gpom="git push origin master" alias gr="git remote" alias gra="git rebase --abort" alias grb="git rebase --committer-date-is-author-date" alias grbom="grb --onto master" alias grbasi="git rebase --autosquash --interactive" alias grc="git rebase --continue" alias grs="git restore --staged" alias grv="git remote -v" alias grh="git reset --hard" alias grH="git reset HEAD" alias grH^="git reset HEAD^" alias gs="git status -sb" alias gsd="git stash drop" alias gsl="git stash list --date=relative" alias gsp="git stash pop" alias gss="git stash show" alias gst="git status" alias gsu="git standup" alias gforgotrecursive="git submodule update --init --recursive --remote"
- psophis 3y agoI use this zsh function and define my git alias in my git config. # No arguments: `git status` # With arguments: acts like `git` function g() { if [[ $# > 0 ]]; then git $@ else git st fi } # Complete g like git compdef g=git
- frfl 3y ago# Complete g like git compdef g=git That's brilliant.
- tacone 3y agoI have my zsh set up so that if I just press Enter without writing anything it will run ls -l or git status if it's a git directory.
- psophis 3y agoHow do you do that? Is it part of your PROMPT?
- tacone 3y agoSorry for the lag, I'll just drop the answer anyway in case it still can be helpful to you or anybody else. It's actually a oh-my-zsh plugin, called "magic-enter". I defined MAGIC_ENTER_GIT_COMMAND="git status" and then included the plugin. You can find a different but similar plugin here: https://github.com/zshzoo/magic-enter/blob/main/magic-enter.plugin.zsh https://github.com/zshzoo/magic-enter/blob/main/magic-enter....
- psophis 3y agoNeat, thanks!
- frfl 3y agoI mentioned this in another comment, but checkout git's builtin support for aliases, defined in ~/.gitconfig [1] And git lets you define custom subcommand if you just create a file like `git-foo` in your $PATH, and then you can run it like `git foo` [1] https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
- jph 3y agoYes and many more git alias commands at https://github.com/gitalias/gitalias https://github.com/gitalias/gitalias