6 ms·
Show HN: Git alias commands and shortcuts
https://github.com/GitAlias/gitalias
Do you use git? I have a big list of alias commands and shortcuts that I'm sharing on GitHub.
I'm seeking suggestions and feedback now, and also seeking pull requests to improve the code.
- brudgers 10y agoDirect link: https://github.com/GitAlias/gitalias https://github.com/GitAlias/gitalias
- alekratz 10y agoI do something similar to this, except I just use my shell's alias do to this. e.g., alias gits="git status". If you're like me and have a weird habit of just typing stuff into the terminal during the day, "gits" (or "git s" if you use OP's stuff) will become one of your most typed commands.
- unhammer 10y agoFor me, it's bash functions "st" (or "sq" to skip untracked); I also made them such that they DTRT in svn, hg, darcs as well. Probably my most used commands :-)
- embiggen 10y agoHow can you justify mapping 'p' to 'pull' rather than 'push'? I applaud the effort and think it's unfortunate the value add seems so marginal here. This type of thing boils down to mostly personal preference.
- jph 10y agoI polled several hundred people during three years. :) In practice, my teams tend to get the most value-add by using purpose-driven aliases for typical pull/push needs. For example, the alias `publish` will push a local topic branch up to a continuous delivery server.
- petetnt 10y agoIf you are a oh-my-zsh user, the Git plugin has tons of aliases ready to use: https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git
- kristjan 10y agoBut you're still typing `git` every time! alias g=git I've got my Git configs up at https://github.com/kristjan/.dotfiles/blob/master/.gitconfig https://github.com/kristjan/.dotfiles/blob/master/.gitconfig if you'd like to sift through them. The very most common, like `git status`, get their own Bash aliases too (https://github.com/kristjan/.dotfiles/blob/master/.aliases#L37-L52 https://github.com/kristjan/.dotfiles/blob/master/.aliases#L...). Who can be bothered to type a space?
- mathgeek 10y agoNot sure if I'm in the majority or minority here, but I actually prefer that the main command (git in this case) not be shortened. The rest of the options are where I find aliasing to be useful. Only because as the numbers of aliases you use grows, it becomes more likely that you'll overwrite your single-letter aliases.
- kristjan 10y agoCertainly everything in moderation - I only give letters to commands I literally type hundreds of times daily. Over the past 10 years, I've accumulated 5: b=`bundle exec`, though this is becoming less often used and I may remove it d=dotenv to easily wrap a command in environment variables (https://github.com/bkeepers/dotenv) g=git h=hub (GitHub's extensions to Git) j=autojump to move to common directories using just a few characters from their name (https://github.com/wting/autojump)
- joshmanders 10y agoI'm the same way, and along with that I don't use aliases directive in my gitconfig either. I create bash scripts that are named git-* that way I can be more advanced in them without having a crappy experience creating them.
- w4rh4wk5 10y agoc = checkout d = diff ds = diff --staged l = log --all --graph --oneline --decorate s = status --short --branch g = grep --break --heading --line-number ff = merge --ff-only puff = pull --ff-only purr = pull --rebase mnc = merge --no-ff --no-commit ignore = update-index --assume-unchanged unignore = update-index --no-assume-unchanged ignored = !git ls-files -v | grep '^[[:lower:]]'
- sdegutis 10y agoRelated: if you use Emacs, look into Magit, it's amazing. https://magit.vc/ https://magit.vc/
- jph 10y agoThanks, I'm adding Magit to the README now.
- felipesabino 10y agoHey, nice usage of "$(git branch-name)" in the commands, I haven't thought about that I have been keeping my gitconfig public [1] it's been a while and I will definitely use this repo as another source to increment it :) [1] https://gist.github.com/felipesabino/6391408 https://gist.github.com/felipesabino/6391408
- jph 10y agoThank you! I'm adding your link to the README now.
- BlakePetersen 10y agoDUDE! Just link the github URL directly next time -- not only should this sort of discussion be done and persist on GH, not a random HN comment thread, but, for whatever reason, iOS won't let me copy that link so I have to type it in manually. Which I won't do. Poor form, buddy. Poor form.
- marcuskaz 10y agoMy favorite: unfuck = reset HEAD --hard
- jph 10y agoHa! That's hilarious. I'll add something like that, with slightly more polite language. :)
- wuthefwasthat 10y agoaliases for opening files, which i find quite useful # open file by name op = "!f() { $(git editor) $(git ls-files | grep -i \"$@\"); }; f" # open currently edited (unstaged) files eop = "! $(git editor) $(git ls-files --modified)" # open files for conflicts (good for rebase/cherry-pick/merge) mop = "!f() { $(git editor) $(git diff --name-only --diff-filter=U); }; f" # open files present in diff dop = "!f() { $(git editor) $(git diff --name-only $@); }; f" # grep and open files containing gop = "!f(){ $(git editor) $(git grep --name-only \"$@\"); }; f" # "show and open" commit shop = "!f() { $(git editor) $(git show --pretty=\"format:\" --name-only $1); }; f" editor = config --get core.editor I wrote a bit about them here: https://wordpress.com/post/wuthefwasthat.wordpress.com/19 https://wordpress.com/post/wuthefwasthat.wordpress.com/19 And all my aliases here: https://github.com/WuTheFWasThat/dotfiles/blob/master/.gitconfig https://github.com/WuTheFWasThat/dotfiles/blob/master/.gitco...
- brbsix 10y agoThat looks like some sort of internal WordPress link. I think you mean: https://wuthefwasthat.wordpress.com/2016/06/18/git-open-aliases/ https://wuthefwasthat.wordpress.com/2016/06/18/git-open-alia...
- michaelmior 10y agoI'm personally a big fan of SCM Breeze[0] [0] https://github.com/ndbroadbent/scm_breeze https://github.com/ndbroadbent/scm_breeze
- jph 10y agoCool, thanks, I'm adding that to the README now.
- seletskiy 10y agoI've got more insane and effective solution: https://github.com/seletskiy/zsh-context-aliases https://github.com/seletskiy/zsh-context-aliases So, aliases will change depending on the directory you're in. And, instead of typing `g s` or `gs` to get `git status` you simply typing `s`.