Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I launch a Git Bash window with particular working directory using a script?

How can I launch a new Git Bash window with a specified working directory using a script (either Bash or Windows batch)?

My goal is to launch multiple Git Bash windows from a single script, each set to a different working directory. This way I can quickly get to work after booting the computer instead of having to open Git Bash windows and navigating each one to the correct working directory.

I am not asking how to change the default working directory, like this question does, but to launch one or more terminal windows with different working directories from a script.

like image 826
holocronweaver Avatar asked Nov 11 '13 21:11

holocronweaver


People also ask

How do I open a git bash window?

Open the Start menu by clicking on the Windows icon and typing “Git Bash” into the search bar. The icon for Git Bash and the words “Git Bash Desktop App” will appear. Click on the icon or the words “Git Bash Desktop App” to open Git Bash.

How do I start Gitbash from command line?

Launch Git Bash console by clicking on the Start button, type git, and click on Git Bash. 2. Run the below git config command to add your name ( YourName ) as your git username ( user.name ). The git config command administers configuration variables that control how Git looks and operates.

How do I change the path in git bash?

To change this current working directory, you can use the "cd" command (where "cd" stands for "change directory"). For example, to move one directory upwards (into the current folder's parent folder), you can just call: $ cd ..


2 Answers

Another option is to create a shortcut with the following properties:

enter image description here

Target should be:

"%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login

Start in is the folder you wish your Git Bash prompt to launch into.

like image 196
Drew Noakes Avatar answered Oct 20 '22 15:10

Drew Noakes


Try the --cd= option. Assuming your GIT Bash resides in C:\Program Files\Git it would be:

"C:\Program Files\Git\git-bash.exe" --cd="e:\SomeFolder"

If used inside registry key, folder parameter can be provided with %1:

"C:\Program Files\Git\git-bash.exe" --cd="%1"

like image 29
Mike Kowalski Avatar answered Oct 20 '22 15:10

Mike Kowalski