integrating Git Bash with Visual Studio
Launch Git Bash from Visual Studio
In Visual Studio Menu Bar: Tools -> External Tools -> Add New
Configuration:
Name: Git Bash
Command: c:\Program Files (x86)\git\bin\sh.exe
Args: --login -i
Initial Dir : $(SolutionDir)
Visual Studio 2019 after v16.6 comes with an integrated terminal similar to the one in Visual Studio Code but its configuration dialog is really buggy as of now. It also doesn't come with a preconfigured git bash, so in order to make it work, you'll have to work around the bugs and create the configuration.
- Go to "Tools -> Options" then "Environment -> Terminal"
- Before changing anything, click the Add button.
- If the bug is present, you will see that your newly created profile has "(Default)" printed behind its name. You now have two default profiles and the integrated terminal as well as the configuration dialog will do weird stuff. If that is the case select the the second profile, i.e. the one that doesn't say "(Default)", click "Set as Default." Now there should only be one default profile left, and everything should behave as normal. In particular, you can set the default to whatever you want. Just make sure that you don't have the default profile selected when you create a new profile because then you'll end up with two default profiles again. It is important to always keep a second profile around, because otherwise you can only add default profiles, which breaks the GUI.
- Configure the bash shell: set the name to something you like (I use "git bash" because I"m boring), as executable use
c:\program files\git\bin\bash.exe
, as Arguments use--login -i
. The shell will be started in your solution's base directory.
You should now be able to use bash in the integrated terminal via the default shortcut Ctrl + ` or via View -> Terminal in the menu.