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?
The working solution listed are great, but the problem occurs when you want multiple default home for your git-bash.
A simple workaround is to start git-bash using bat script.
cd C:\xampp\htdocs
"C:\Program Files\Git\git-bash.exe"
The above of course assume git-bash is installed at C:\Program Files\Git\git-bash.exe
You can create multiple .bat
file so your git-bash can start where it want to be
The easiest way without installing msysgit is right click on the Git Bash shortcut icon → Start in: → "C:\Program Files (x86)".
Change the Start in entry and point out the Git Bash starting position. If you don't remove the --cd-to-home
part from the Target box, the Start in change gets overridden.
I read it somewhere and it worked for me.
First check in git bash what is the HOME location. Open git bash and run
echo $HOME
Now change the HOME path by opening cmd and run
setx HOME "path/to/.ssh/loc" (I gave C:\Users\aXXXX)
Now cross check by running the echo command in git bash.
Git bash is used to play with bash commands. So I use bash method itself in windows Git bash
Edit your .bash_profile
(create it if you doesnot have one - see below how to create). Enter the following lines.
alias ws="cd /d/workspace/"
ws
Smilyface@SmilingMachine /d/workspace
$ cat ~/.bash_profile
alias ws="cd /d/workspace/"
ws
touch ~/.bash_profile
OR write into the file directly
vi ~/.bash_profile
Simple, aha !
Once you have updated the Start in:
field make sure to remove the --cd-to-home
at the end of the Target:
field
Windows 10 tested solution
Type git bash in search
Right click on it and choose open file location
Right click on it and choose properties
At target remove --cd-to-home from "C:\Program Files\Git\git-bash.exe" --cd-to-home
At start in put the path of the directory you want it to start at for example Start in: C:\xampp\htdocs