Windows – Git: Open Git-Bash in specific directory

cmd.exegitwindows 7

I am able to start git-bash via the Windows command prompt in several ways:

"C:\Program Files\Git\bin\sh.exe"
"C:\Program Files\Git\git-bash.exe"
"C:\Program Files\Git\usr\bin\mintty.exe"

I would like to start git-bash in a particular directory using such a call.


For context, I am doing this from within the SAS Enhanced Editor. The actual call is

%sysexec(start "" "C:\Program Files\Git\bin\sh.exe" && exit);

For those unfamiliar with SAS, %sysexec opens an instance of the Windows Command Prompt and issues whatever command is given as an argument.
It works surprisingly well. However, I would like to be able to start the git-bash in a particular directory, not just home.

To this end, I can create an entry in .bashrc:

cd /c/new/starting/dir

The trouble with doing this, though, is whenever I open a git-bash, such as via the context menu in a particular folder, the default directory is that of .bashrc.

I see that there exist git-bash start options like --cd-to-home or --cd=<path> but I can't get them to work. For example,

"C:\Program Files\Git\bin\sh.exe" --cd-to-home
"C:\Program Files\Git\bin\sh.exe --cd-to-home"
"C:\Program Files\Git\git-bash.exe" --cd-to-home
"C:\Program Files\Git\git-bash.exe --cd-to-home"
etc.

Is it possible to start git-bash in a particular directory from Windows Command Prompt? If so, what's the proper syntax?

BONUS: Bonus points for doing it in 50 characters or less

Best Answer

"C:\Program Files\Git\git-bash.exe" --cd=c:\path\to\folder
Related Question