将 Git Bash 与 Visual Studio 集成

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8025108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 12:15:20  来源:igfitidea点击:

integrating Git Bash with Visual Studio

visual-studiogit

提问by Andy

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.

我有一个 Windows 版本的 Git Bash,我想将它与我的 Visual Studio 项目一起使用。我想要的是一种调整某些设置的方法,以便单击可以使用当前 Visual Studio 项目上的目录打开 Bash。

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.

如果有一种方法可以在 Git Bash 中为目录设置快捷方式,这样一个命令就可以让我进入预设目录,那就太好了。

采纳答案by manojlds

Have a look at Git Source Control Provider: http://gitscc.codeplex.com/

看看 Git 源代码控制提供程序:http: //gitscc.codeplex.com/

It has Visual Studio integration for Git and one of the options is to bring up Git Bash.

它具有适用于 Git 的 Visual Studio 集成,其中一种选择是启动 Git Bash。

回答by Tarun

Launch Git Bash from Visual Studio

从 Visual Studio 启动 Git Bash

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

在 Visual Studio 菜单栏中: 工具 -> 外部工具 -> 添加新工具

Configuration:

配置:

Name: Git Bash

名称:Git Bash

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

命令:c:\Program Files (x86)\git\bin\sh.exe

Args: --login -i

参数:--login -i

Initial Dir: $(SolutionDir)

初始目录:$(SolutionDir)

回答by ihorbond

In VS2017 I added mine by going to Tools -> External Tools -> Add

在 VS2017 中,我通过转到 Tools -> External Tools -> Add 添加了我的

  • Title: Git Bash
  • Command: C:\Program Files\Git\git-bash.exe
  • Initial directory: $(SolutionDir)
  • 标题:Git Bash
  • 命令:C:\Program Files\Git\git-bash.exe
  • 初始目录:$(SolutionDir)

Note: Use Output window runs the command and puts any output into the Output window. This is useful for commands that just return some data so I didn't check it.

注意:使用输出窗口运行命令并将任何输出放入输出窗口。这对于只返回一些数据的命令很有用,所以我没有检查它。

If you want to create a shortcut for it:

如果要为其创建快捷方式:

  1. Use MoveUp to move 'Git Bash' to the 1st position.
  2. Go to Tools -> Options -> Environment -> Keyboard and search for Tools.ExternalCommand1
  3. Assign shortcut
  1. 使用 MoveUp 将“Git Bash”移动到第一个位置。
  2. 转到工具 -> 选项 -> 环境 -> 键盘并搜索 Tools.ExternalCommand1
  3. 分配快捷方式

回答by vibs2006

I'll recommend you using GIT Tools for Visual Studio 2013 onwards

我会推荐你​​使用 GIT Tools for Visual Studio 2013 以上

You can know its complete help information by visiting http://yysun.github.io/git-tools/#/

访问http://yysun.github.io/git-tools/#/即可了解其完整的帮助信息

To install it go in Tools -> Extensions and Updatesand type Git Tools. Download the plugin and install or you can simply visit visual studio market place https://marketplace.visualstudio.com/items?itemName=yysun.GitToolsand click on download.

要安装它,请进入Tools -> Extensions and Updates并输入Git Tools。下载插件并安装,或者您可以直接访问 Visual Studio 市场https://marketplace.visualstudio.com/items?itemName=yysun.GitTools并单击下载。

Snapshot of Git Tools

Git 工具快照

Once you have installed Git Tools extension and restarted all opened instances of visual studio

安装 Git Tools 扩展并重新启动所有打开的 Visual Studio 实例后

To Launch Git Bash:* Click on Git Tools -> Git Bashas shown below

启动 Git Bash:* 点击Git Tools -> Git Bash,如下图所示

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

However before performing these steps please ensure that you have git bash https://git-scm.com/downloadsinstalled completed on your environment and most probably configured your logins if possible.

但是,在执行这些步骤之前,请确保您已经在您的环境中安装了git bash https://git-scm.com/downloads,并且如果可能的话,很可能配置了您的登录。

回答by dahlbyk

You can use posh-gitin the NugetPackage Manager Console, which automatically switches to the location of the open solution.

您可以在Nuget包管理器控制台中使用posh-git,它会自动切换到打开的解决方案的位置。