Show HN: Git alias commands and shortcuts
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.
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.
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.
alias g=git
I've got my Git configs up at 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#L...). Who can be bothered to type a space? 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) # 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/19And all my aliases here: https://github.com/WuTheFWasThat/dotfiles/blob/master/.gitco...
https://wuthefwasthat.wordpress.com/2016/06/18/git-open-alia...
c = 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:]]'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 :)
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.
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.
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`.
unfuck = reset HEAD --hardPoor form, buddy. Poor form.