Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

integrating Git Bash with Visual Studio

I have a windows version of Git Bash, and I want to use it with my Visual Studio Projects. What I want is a way of tweaking some setting so that one click can get Bash opened with the directory on the current visual studio project.

It would be great if there's a way to set up short cut in Git Bash for directories, so that one command can get me to a preset directory.

like image 817
Andy Avatar asked Nov 06 '11 03:11

Andy


People also ask

Does Visual Studio support bash?

By this way you can access Git Bash with simply typing bash in every terminal including the integrated terminal of Visual Studio Code.

Why Git bash is not showing in VS code?

The solution is to uninstall git and reinstall it in the default location which is (C:\Program Files\Git). All the other hacks failed. Show activity on this post. By configuring profile as bash in the above format it worked finally!!!


2 Answers

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)

like image 191
Tarun Avatar answered Sep 29 '22 02:09

Tarun


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.

  1. Go to "Tools -> Options" then "Environment -> Terminal"
  2. Before changing anything, click the Add button.
  3. 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.
  4. 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.

like image 21
tobi_s Avatar answered Sep 29 '22 01:09

tobi_s