How do I change the default location for Git Bash on Windows?

后端 未结 18 1014
暗喜
暗喜 2020-11-28 01:32

I am using Git on Windows 7 and access my repositories through Git Bash. How can I change the default location that Git Bash opens in a convenient folder when I start it?

18条回答
  •  隐瞒了意图╮
    2020-11-28 02:24

    I liked Peter Mortenson's answer, but I would like to expand.

    'cd ~' in the .bashrc file causes the "Git Bash Here" feature of Git Bash to stop working. Instead, add this if statement to the .bashrc file:

    if [ "$PWD" == '/' ]
    then
            cd ~
    fi
    

    This will change to the home directory when Git Bash is run on its own, but when "Git Bash Here" is run, the current working directory will not be changed.

提交回复
热议问题