6 ms·
I also have aliases in my shell instead of git aliases. st git status ... gl git log ... gd git diff ... gg gitg gup git pull
by qznc 9y ago
I also have aliases in my shell instead of git aliases.
st git status ...
gl git log ...
gd git diff ...
gg gitg
gup git pull --rebase
gb git branch
The dots mean there are more arguments. The point is, every once in a while I analyse my shell history and add aliases for the most used commands. Looking at it now, it seems I should add aliases for `git push` and `vi Makefile`.
I also have the aliases g for git, m for make, and v for vim.
- fredley 9y agoYes, I have similar: gs git status gp git push gac git commit -am gc git commit gcm git commit -m gA git add -A gC git checkout ga git add gd git diff gm git merge gmc git merge --continue gpu git pull grc git rebase --continue The only problem is that I cannot use git on anybody else's machine, the muscle memory is too strongly ingrained now. This is a common message: The program 'gs' is currently not installed. You can install it by typing: sudo apt install ghostscript
- elcapitan 9y agoWhich is better than if they have the same aliases as you, but they mean something else. I had an interesting time a while ago until I understood that my coworker uses 'st' for stash instead of status.
- daemin 9y agoIt also means that you can't use any common tools that use the same letters as your shortcuts.
- fredley 9y agoTrue, if I ever need to use ghostscript (whatever it is) in my day-to-day life, it'll be a trainwreck.
- asdfgadsfgasfdg 9y agoIt's a ps/pdf toolkit type program. It is used by imagemagick as a backend for pdf conversion type stuff - so if you every need imagemagick you might find yourself in for some annoyance as well.
- hashhar 9y agoAliases are only expanded in interactive shells so ImageMagick or any program that calls an executable from within a process will not have any issues.
- elcapitan 9y agoI'm actually using them as git aliases, not bash command aliases.
- jlgaddis 9y agoYou can, you just have to prefix them with a hyphen, e.g.: $ -gs
- danellis 9y agoHow much time does that actually save? I find that for any given task, I spend far more time reading and thinking than I do typing, and of the time spent typing, most of it is spent typing arguments.
- jachee 9y agoThe shorter a command is, the fewer typos can be made. Many times have I typed `git stauts` or `git ocmmit` Of course, my personal solution instead of aliases was to switch to using SourceTree.
- herrvogel- 9y agoI discovered https://github.com/nvbn/thefuck https://github.com/nvbn/thefuck a while ago and now I kind of enjoy making typos like this.
- fredley 9y agoFor me, at least a day in 5 years: https://xkcd.com/1205/ https://xkcd.com/1205/
- akavel 9y agoI use `git diff` and `git log --graph --decorate --all --oneline` and `git status` so often, that it totally saves heaps of time. Especially the second one ― I usually type my `gl` somewhat subconsciously already; only afterwards I realize what I'm looking at, and start reading. That's possibly related to the fact that I commit very often, use many working branches, and then rebase -i (usually squashing and composing a good readable commit message) before publishing. But anyway, if someone asks for help with "how to fix my mess in git", the absolutely first thing I do is exactly `git log --graph --decorate --all --oneline`, to start finding out visually what the mess actually is.
- angry-hacker 9y agoWouldn't it be easier to use fish or something else with autocomplete support?
- henrik_w 9y agoI have similar aliases and have a similar concern. I usually think "git status" when I type gs. This way I hope I would be able to work without my aliases somewhere else (even though it would take longer since I have to remember to type the whole command).
- piinbinary 9y agoA few more I find useful: gdc git diff --cached gg git grep -n gss git status -s glo git log --oneline gamend git commit --amend --no-edit
- c0achmcguirk 9y agoI have the exact same alias for git status and I'm very familiar with that error message! A few more I live and die by: gf git fetch --all; git fetch --tags gh git log --oneline --abbrev-commit --all --graph --decorate
- akavel 9y agoIIUC, the --abbrev-commit is unnecessary there, --oneline already does it. Makes the incantation possible to remember and type on a foreign console: "git log --graph --oneline --decorate --all" edit: yep, per git help log: --oneline This is a shorthand for "--pretty=oneline --abbrev-commit" used together.
- c0achmcguirk 9y agoThanks!
- fenollp 9y agoHere is my own DSL. Interesting that it turns out we have similar aliases... alias ga='git add' alias gb='git branch' alias gbD='gb -D ' alias gbc='gc -b ' alias gbd='gb -d ' alias gc='git checkout' alias gcm='git checkout master' alias gd='git diff ' alias gdd='gd --cached' alias gdm='gd master...' alias ge='git grep -InE ' alias gec='git branch --remotes --contains ' alias geh='git log --all --oneline --decorate -G ' alias gei='ge -i' alias gff='gh && gpr && gr && ghp' alias gfm='b=$(gw) && [[ "$b" != master ]] && gcm && gpr && gfu && gr && gc $b && unset b' alias gfr='git fetch && git rebase origin/master' alias gfu='git fetch upstream && git merge upstream/$(gw)' alias gh='git stash' alias gha='gh -k' alias ghp='gh pop' alias ghs='gh show -p ' alias gl='git log --graph --decorate --all' alias gll='gl --pretty=format:"%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s" --relative-date' alias glll='gl --color --graph --pretty=format:'\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset'\'' --abbrev-commit' alias gp='git pull ' alias gpr='git pull origin $(gw)' alias gps='git push' alias gpt='gps --tags' alias gr='git push origin $(gw)' alias grr='git rebase -i HEAD~$(grrr | wc -l)' alias grrr='git rev-list master..' alias grt='gr --tags' alias gs='git status' alias gss='git show' alias gu='git config --get remote.origin.url' alias gv='git describe --abbrev --dirty --always --tags' alias gw='git rev-parse --abbrev-ref HEAD 2>/dev/null' alias gx='git archive --format tar --remote '
- Sharlin 9y agoI especially like the "grr" and "grrr" aliases. I have those days too...
- mikegerwitz 9y agoYou might be interested in this: https://mikegerwitz.com/projects/git-shortmaps/about/ https://mikegerwitz.com/projects/git-shortmaps/about/ It creates the aliases as you do, but also includes tab completion, and only takes effect when you're in a repository path.
- cormacrelf 9y agoIf shell aliases don't tab-complete for you, you can get tab completion just by defining git aliases instead. One extra space if you also alias g=git. And it solves namespacing.
- Theodores 9y agoI find this reassuring as I sometimes feel behind the times for using command line git instead of some fancy WYSIWYG interface. Am I in a minority or not? Is command line the preferred way and if so is it more productive? I just do commits to master, I don't do fancy hotfixes, feature branches squashed to master or fancy bisects. Maybe a merge conflict in my colleague's CSS is as hard as it gets for me.
- shandor 9y agoSeriously, the more complex your use case is, the better the command line gets. Personally, I use mostly command line git and on occasion a little bit of gitk if I get lost between all the branches. I die a little (read: a lot) inside when I have to help my team members with git and they adamantly stick to TortoiseGit. It's a prime example of the UI improving discoverability at the expense of performance (and even then the individual actions tend to get lost between all the numerous possible actions).
- qznc 9y agoThis discussion got me thinking about my push habits. While I only have to type `g psh`, the actual process has more commands. I check that I'm on the correct branch, check which commits will get pushed, and maybe even the diffs of the commits. Sometimes I have to rebase, fixup, and squash stuff. It is similar for committing, where checking diffs and partial adding is part of the process. Using an IDE or GUI might help to streamline this. I do not use any, so I don't know if they do this. Maybe I should analyse my shell history for sequences?
- ooqr 9y agoMaybe check this out? I use it all the time (the zsh integration). https://github.com/powerline/powerline https://github.com/powerline/powerline
- gknoy 9y agoI also like to alias `gd-` for `git diff --cached`, for checking what I have staged so far in my index.
- jsm 9y agoSCM Breeze does a nice job of this: https://github.com/scmbreeze/scm_breeze https://github.com/scmbreeze/scm_breeze