Domanda

I have created a goToProject.bat file with this content:

cd C:\Dev\MyProject

I want to run the goToProject.bat using Git Bash because i don't want to manually go to the folder every time i have to use git in my project.

To run the goToProject.bat from Git Bash i can do that:

$cmd goToProject.bat

Doing this the goToProject.bat runs but the console transforms to the windows cmd console and if i do:

c:\Dev\MyProject> exit

The console transforms again to Git Bash console but in the default route.

How i can run the goToProject.bat and stay in the Git Bash console?

È stato utile?

Soluzione

I already found what I needed:

To open git bash directly from visual studio without having to manually type the project root folder every time, just add a new external tool command:

  • In Visual Studio Menu Bar: Tools -> External Tools -> Add New

  • Title: Git Bash

  • Command: c:\Program Files (x86)\git\bin\sh.exe

  • Args: --login -i

  • Initial Dir: $(SolutionDir)

Doing this, you can search 'Git Bash' under 'Tools' on the Visual Studio Menu Bar and git bash will be opened within your project folder.

Also, you can set a shortcut to your external tools:

  • In Visual Studio Menu Bar: Tools -> Options -> Environment -> Keyboard
  • In Show commands containing type: Tools.ExternalCommand
  • Choose the command you want (the number of the external tool is the position in the list) * Set a shortcut for it (e.g, Ctrl+G, Ctrl+B)

Altri suggerimenti

Just write up a .sh script instead of a .bat file.

Here's more info: GIT Bash - how to default to other directory instead of home directory

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top