Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save edwardchanjw/4054039 to your computer and use it in GitHub Desktop.
Save edwardchanjw/4054039 to your computer and use it in GitHub Desktop.
Git for Windows tip: Setting shell aliases with msysgit
As msysgit uses a bash shell, you can set really handy aliases for the different git commands. For example gs instead of git status and ga instead of git add are the ones I use the most. Check out the great Git Immersion tutorial from Edgecase for a list of aliases. I can also recommend creating the got and get aliases. It’s amazing how often I write got instead of git.
Using the bash shell can be unfamiliar to a Windows user. So if you want to set aliases in msysgit it is not very obvious where they should go. They could go into the .bashrc file or the bash_profile file. From a linux perspective the bash_profile configuration file is executed when logging in while the .bashrc file is executed every time a bash shell window is opened. The .bashrc file is located in the c:\Users\YourUsername directory and the bash_profile file is in the etc directory. In the case of msysgit I fail to see that there is any real practical difference; both are executed when you start up msysgit. So I just used .bashrc and it works great.
If there is no file named .bashrc then you’ll have to create it. Windows 7 will not allow you to create a file with a dot (period) as the first character in the filename and with no extension. So the easy way to do this is to name your file .bashrc. (with an extra dot at the end) and Windows will automatically rename the file to just .bashrc (with no dot at the end).
My .bashrc file (almost identical to the Git Immersion profile file that is linked above):
01 alias less='less -r'
02 # --show-control-chars: help showing Korean or accented characters
03 alias ls='ls -F --color --show-control-chars'
04 alias ll='ls -l'
05 alias gs='git status '
06 alias ga='git add '
07 alias gb='git branch '
08 alias gc='git commit'
09 alias gd='git diff'
10 alias go='git checkout '
11 alias gk='gitk --all&'
12 alias gx='gitx --all'
13 alias got='git '
14 alias get='git '
@vrufine
Copy link

vrufine commented Mar 8, 2017

get and got aliases = the best :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment