Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Git Bash on Windows 7 and would like to set up bash profile aliases such as alias gs='git status' to make my life easier. How can I do this?

share|improve this question
up vote 54 down vote accepted

When you open up your Git Bash, you should be in your home directory by default. Now create the .bashrc file (if on Win7 the file should be named .bashrc.). If you're not in the home directory, change into it by typing:


and pressing Enter. cd, without any other parameters listed after, will always return the home directory.

You can create the file by typing:

touch .bashrc

Then edit it with vim or you could try doing it with some windows editor, but I don't recommend it, because of some text formatting issues.

vim .bashrc

Change to Insert Mode by hitting the i key.

Add your alias by typing:

alias gs='git status'

Exit the insert mode by hitting the ESC key.

Save and close your file by typing the following :wqEnter.

:wEnter will only save your file.

:q!Enter will quit the editor without saving your file.

Finally, update the file to use your new changes by typing:

source .bashrc

share|improve this answer
Thanks for your answer. I didn't know about .bashrc before, so your answer lead me to several sources, including…;, that agree that .bashrc is a better place to put aliases than .bash_profile. – Brian Jun 3 '13 at 15:07

You can put .bash_profile in your user directory: C:\Users\<username>.

You can also create some git-only aliases so you can do just git st for git status by adding these lines to C:\Users\<username>\.gitconfig:

st = status

Some other useful aliases:

cm = commit -m
cma = commit -a -m
br = branch
co = checkout
df = diff
ls = ls-files
sh = stash
sha = stash apply
shp = stash pop
shl = stash list
mg = merge
ph = push -u
share|improve this answer
If aliases for Git commands are needed, editing the .gitconfig file is usually sufficient. – Isxek Jun 2 '13 at 21:45
Thanks for your answer! I wasn't expecting to get two different but correct answers. – Brian Jun 3 '13 at 15:11

In your git bash home directory, there should be a .gitconfig file. In this file you can add your aliases by adding [alias]. It should be something like below:

st = status
co = checkout
share|improve this answer
Welcome to Super User! This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute. – DavidPostill Jul 5 at 9:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .