Git for Windows doesn't execute my .bashrc file

后端 未结 4 2087
渐次进展
渐次进展 2020-12-24 00:57

I\'ve just installed Git for Windows 2.5.0 on Windows 7, and it appears that my .bashrc file is not being executed when I run Git Bash.

I created the fi

相关标签:
4条回答
  • 2020-12-24 01:21

    A bit late on this answer perhaps, but you could call bash with the -rcfile argument followed by the location of your .bashrc file.

    bash -rcfile C:\Users\name\.bashrc
    

    I've added this to the end of my PowerShell profile (.ps1 file) so that Powershell automatically opens in bash and configured to my preferences.

    0 讨论(0)
  • 2020-12-24 01:24

    Same thing happened to me when I upgraded to Git Bash 2.5.0 in Windows 10. I renamed my '.bashrc' -> '.bash_profile' and relaunched Git Bash. Everything's working as usual again.

    mv ~/.bashrc ~/.bash_profile
    
    0 讨论(0)
  • 2020-12-24 01:29

    It appears the latest version of git for Windows (2.8.3.windows.1) uses a 'profile' file now instead of the .bash_profile. I assume this is so it isn't hidden and a valid file name. Didn't seem to cause any issues before, but maybe it was confusing to people.

    0 讨论(0)
  • 2020-12-24 01:36

    OK, I found out the problem. Quite simply, the bash terminal used by the latest Git for Windows 2.5.0 (mintty) doesn't bother to read .bashrc - it reads .bash_profile. So you can set up your environment in .bash_profile and/or put this code at the start to read .bashrc:

    if [ -f ~/.bashrc ]
    then
        . ~/.bashrc
    fi
    
    0 讨论(0)
提交回复
热议问题