Use 'g' as an Alias for 'git' without Losing Autocompletion 1
I've just started using a new kind of abbreviation system for Git:
- I use 'g' instead of 'git',
- I've set up bash autocompletion for 'g', just like 'git'.
Previously, I used the following in my ~/.bashrc:
... alias gts='git status' alias gtd='git diff' ...The problem is that, by doing this, you lose autocompletion.
Setup
Set Up 'g' as an alias for 'git'
In ~/.bashrc:
... alias g='git' ...
2. Locate the Bash Completion File for Git
Locate your bash_completion.d directory:
- On Linux, /etc/bash_completion.d
- I'm using OS X with Mac Ports, so mine is at /opt/local/etc/bash_completion.d.
git-completion.bash
3. Add Completion for 'g'
Add the following to the end of git-completion.bash:
complete -o bashdefault -o default -o nospace -F _git g 2>/dev/null \ || complete -o default -o nospace -F _git g
$ g |<TAB>you should see autocompletion:
$ g | add commit init request-pull am config instaweb reset annotate describe log revert ...
Show your Git Branch Name in your GNU Screen Status Line
I think my shell prompt is already cluttered enough, so I decided to show my current git branch in my GNU Screen status line instead.
Shared Git Repositories
When you want to have a central shared git repository to push commits to, there are two common configurations:
1. Everybody uses the same user for commits - easy to set up, but very messy,
2. Create a system user for each committer, create a system group for each project and add users to relevant groups.
The post explains how to set up and manage configuration the second option.