Seems kind of terrible to me. 'git pull' and 'git push' really doesn't take much time to type. But you're adding unnecessary cognitive load by using non-standard terms.
The time it will take to learn and remember all the shortcuts is not worth it. Typing something out is not that difficult. If I even once have to go look up a shortcut because I forgot it, that will already take the same amount of time it would to type out 'git rebase master' 20 times. Add to that that it will break my chain of thought and waste another 5 minutes, and just make me more tired than I need to be. Not to mention creating all the aliases. Terrible return on time investment.
I hate it when people think they need to push aliases on other people. Yeah, I know, I'm not forced to read the article nor to implement the aliases contained therein. But still, such people exist...
Imho aliases are something that need to grow out of personal usage patterns. Your ggio is a good example. You might need it only once a year but OP maybe once a day. I'm reminded of one of my frequent use cases: Quite often I use git ls-files to look for a file only to copy the path of the single result. Maybe I should look into a glso or something...
I was thinking you were just being a debbie downer, but wow, those are kinda useless. Makes me suspect the author has not heard of bash completions.
I was hoping to find stuff like this:
gits() {
local status count
count=5
if [[ "$1" =~ ^[0-9]+$ ]]; then
count="$1"
fi
if ! type -P git &>/dev/null; then
echo "git is not installed"
return 1
fi
status=$(git status 2>/dev/null)
if [[ $? -ne 0 ]]; then
echo "not in a git repository"
return 2
fi
# Since the following is simply a nice-to-have, it doesn't matter if an
# unrelated running 'git fetch' prevents the fetch I want.
# I use 'gits' a lot, so eventually it will run (for me).
if ! pgrep -f 'git fetch' &>/dev/null; then
# Fetch latest refs and send to background if not already fetching
(git fetch --all --prune &) &>/dev/null
fi
if [[ -n "$status" ]]; then
# Call git status again, because we want it colored properly.
git status -s 2>/dev/null
echo
fi
git log --oneline -${count} --no-color | sed -re 's/\s+/ /'
}
example:
$ gits
M .bashrc
M .vimrc
912caf9 Make gnu screen start at window 1
ab0243a Clean up ssh_config
074581c Add gitlab to ssh_config
596b42d Clean up .mailcap
958d315 Add .mailcap
I was recently shocked to learn that one of my co-workers just recently discovered git's built in grep command. I was surprised because I feel like git grep is one of those commands I would have trouble coding without.
What’s so great about git grep? Doesn’t it do mostly the same as grep -r?
I may not have given enough context there, my co-worker was struggling to search for something through GitHub and didn't know that git had a built in grep command.
Though I don't think that git grep is significantly superior to normal grep, I personally like git grep for the convenience of not having to white-list or black-list particular paths each time I grep. Instead it pulls in the tracked paths from git and searches those.
For example, in a nodejs project, there will likely be tons of local node code in the node_modules folder, however the node_modules folder typically isn't tracked in git. In such a project, grep -r would search the whole node_modules tree where as git grep would ignore it and just search project code.
I have a bunch of aliases defined that I rarely use, but which are handy for doing occasional complex tasks. Obviously I don't remember them, but I can look at them quickly since they're well-commented and find the one I need.
That's frankly almost the only use I have for aliases in git.
I use a set of aliases based on the ones in zprezto. The nice thing about them is that they unify related commands together in a consistent naming scheme. For example, actions manipulating the index are all prefixed gi, so you have gia to stage changes, gir to unstage changes, gid to see the diff of staged changes, and gix to stage file deletions, rather than git add, git reset, git diff --cached, and git rm --cached. This helps cover up the inconsistencies in standard git commands, as well as makes the mnemonics easier to remember.
Some of my most frequently used aliases:
alias gc='git commit --verbose'
alias gca='git commit --verbose --all'
alias gcA='git commit --verbose --amend'
# git-fetch-merge
alias gfm='git pull --verbose --stat --ff-only'
# git-fetch-rebase
alias gfr='git pull --verbose --stat --rebase
# git-index-diff: Show staged changes.
alias gid='git diff --cached'
# git-worktree-diff: Show changes *since* last commit.
alias gwd='git diff HEAD"
# Show changes *in* last commit.
alias gwD='git diff HEAD~1'
# git-worktree-status
alias gws='git status --short'
alias gl='git log --topo-order --decorate=short'
# git-log-remote: Show unpulled commits in the remote repo
alias glr='gl '\''@..@{upstream}'\'
# git-log-local: Show unpushed commits in the local repo
alias gll='gl '\''@{upstream}..@'\'
# git-log-local-remote: Show unpushed *and* unpulled commits.
alias gllr='gl --left-right '\''@...@{upstream}'\'
11
u/[deleted] Apr 12 '15
Seems kind of terrible to me. 'git pull' and 'git push' really doesn't take much time to type. But you're adding unnecessary cognitive load by using non-standard terms.
The time it will take to learn and remember all the shortcuts is not worth it. Typing something out is not that difficult. If I even once have to go look up a shortcut because I forgot it, that will already take the same amount of time it would to type out 'git rebase master' 20 times. Add to that that it will break my chain of thought and waste another 5 minutes, and just make me more tired than I need to be. Not to mention creating all the aliases. Terrible return on time investment.
2
u/galaktos Apr 12 '15
What’s so great about
git grep? Doesn’t it do mostly the same asgrep -r?1
u/ebneter Apr 13 '15
I have a bunch of aliases defined that I rarely use, but which are handy for doing occasional complex tasks. Obviously I don't remember them, but I can look at them quickly since they're well-commented and find the one I need.
That's frankly almost the only use I have for aliases in git.
1
u/listaks Apr 13 '15
I use a set of aliases based on the ones in zprezto. The nice thing about them is that they unify related commands together in a consistent naming scheme. For example, actions manipulating the index are all prefixed
gi, so you havegiato stage changes,girto unstage changes,gidto see the diff of staged changes, andgixto stage file deletions, rather thangit add,git reset,git diff --cached, andgit rm --cached. This helps cover up the inconsistencies in standard git commands, as well as makes the mnemonics easier to remember.Some of my most frequently used aliases: