3 ms·
Nothing esoteric, but I advise every person I teach git about to put this in their .bashrc: alias s='git status' alias l='git log --graph --oneline --d
by SonOfLilit 10y ago
Nothing esoteric, but I advise every person I teach git about to put this in their .bashrc:
alias s='git status'
alias l='git log --graph --oneline --decorate --all --show-signature'
alias d='git diff'
alias dc='git diff --cached'
alias c='git commit -m'
alias ca='git commit -am'
alias a='git add -p'
alias u='git checkout -p'
These probably saved me hours of typing by now. Especially `l` I think should be canon.
- cm3 10y agoI don't know if you're aware, so this is just a friendly suggestion: if you define these as git aliases instead, you won't use your shell's namespace and have it available for other aliases. As git aliases you would run it like `git s` or `git ca`. If you also alias git to g it will be `g ca`. If you do that, don't forget to call `__git_complete g __git_main` in .bashrc for it to auto-complete aliases for `g` and not just `git`. For example, to define `ca`, run this git config --global alias.ca 'commit -am'
- SonOfLilit 10y agoI am of course aware of git aliases (e.g. because OP uses them a lot) but it never occured to me specifically to shorten git to g and find a way to keep autocomplete working. However, since these are by far my most typed commands (specifically, probably 40% of my executed commands are `s`), I strongly care about the difference even between 1 and 3 keystrokes. Thanks for your feedback. I wonder if the downvote was because of using bash aliases or for something more substantial...
- cm3 10y agoI never downvote anything, so I'm not sure, but maybe the use of "advise" and "canon" triggered negative votes?
- SonOfLilit 10y agoThanks (if you're still reading this thread), I didn't know "advise" carried negative connotations. I guess it's one of those words that I learned from a dictionary and never stopped to notice that English speakers use it only in much more formal situations than the word in my native language that I'm trying to evoke. Should that maybe have been "recommend"?
- cm3 10y agoEnglish isn't my 1st language either, but the power of downvotes is misused a lot on the internet, especially when there's no public trail who downvoted. Advise and canon may just carry too strong of a meaning for those who grew up in English-speaking school systems.
- iamthad 10y agoWhile it will end up being a little longer, these can all be defined as aliases within git (see https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases). Some users might prefer the aliases there rather than in their shell configuration.