Git for Windows: .bashrc or equivalent configuration files for Git Bash shell

Viewed 315957

I've just installed Git for Windows and am delighted to see that it installs Bash.

I want to customise the shell in the same way I can under Linux (e.g. set up aliases like ll for ls -l), but I can't seem to find .bashrc or equivalent configuration files.

What should I be editing?

14 Answers

Just notepad ~/.bashrc from the git bash shell and save your file.That should be all.

NOTE: Please ensure that you need to restart your terminal for changes to be reflected.

Please use the following command,

cat /etc/bash.bashrc > ~/.bashrc

This will generate a new bashrc file with the default values. Please use vi ~/.bashrc to edit this file.

go to: C:\Program Files\Git\etc\profile.d inside you find all you need it.
Or in your home directory create .bashrc and .bash_profile.

.bash_profile

# generated by Git for windows
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc

.bashrc

echo "Hello World!"

Don't need to create a new file, it is already there!

/etc/bash.bashrc

In your home directory, you should edit .bash_profile if you have Git for Windows 2.21.0 or later (as of this writing).

You could direct .bash_profile to just source .bashrc, but if something happens to your .bash_profile, then it will be unclear why your .bashrc is again not working.

I put all my aliases and other environment stuff in .bash_profile, and I also added this line:

echo "Sourcing ~/.bash_profile - this version of Git Bash doesn't use .bashrc"

And THEN, in .bashrc I have

echo "This version of Git Bash doesn't use .bashrc. Use .bash_profile instead"

(Building on @harsel's response. I woulda commented, but I have no points yet.)

for gitbash in windows10 look out for the config file in

/.gitconfig file

On Windows:

you can find .bashrc in the directory: C:\Users\[YourUserName]

Related