windows 如何在 git bash 中注册新安装的驱动器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5197540/
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-15 16:20:14  来源:igfitidea点击:

How to register newly mounted drive in git bash?

windowsgitbashmountdrive

提问by ?ukasz Podolak

In my day-to-day work (I'm using MS Windows), I keep my git bash (actually using console2for this) open for the whole day. It is also very frequent that I mount new drives that I would like to work with git. However I noticed that I need to exit the bash and open it again in order to make it recognize new drive letter.

在我的日常工作中(我使用的是 MS Windows),我将我的 git bash(实际上是使用console2)打开一整天。我也经常安装想要使用 git 的新驱动器。但是我注意到我需要退出 bash 并再次打开它以使其识别新的驱动器号。

Is there any command that 'registers' already mounted drive in git bash ? thanks

是否有任何命令可以在 git bash 中“注册”已经安装的驱动器?谢谢

edit2: I do not have any option to left a comment under my own question (weird ..?), so I post it here:

edit2:我没有任何选项可以在我自己的问题下发表评论(奇怪..?),所以我把它贴在这里:

$ mount -a
sh.exe": mount: command not found

采纳答案by jaypb

Couple of things, had some difficulty finding sources so feel free to take it with a grain of salt.

有几件事,在寻找来源时遇到了一些困难,因此请随意接受。

  1. Msysgit simply doesn't include a version of mount. It is my understanding that cygwindoes, however. There is no simple way to either view all attached drives or mount a new drive in msys, and thus Git Bash.
  1. Msysgit 根本不包含mount. 然而,我的理解是cygwin确实如此。没有简单的方法可以查看所有连接的驱动器或在 msys 中挂载新驱动器,因此 Git Bash。

To answer your question, you don't: Git Bash does not dynamically assign drives, so if you mount new drives, you need to close all instances and restart Git Bash (source). The source referenced there is cached here. Sorry there's not a nicer solution.

要回答您的问题,您不需要:Git Bash 不会动态分配驱动器,因此如果您挂载新驱动器,则需要关闭所有实例并重新启动 Git Bash()。此处引用的源缓存在此处。抱歉,没有更好的解决方案。

回答by Matt Robinson

I commonly mount a drive to the file system and then have to run a script that alters some files on the from within a Git Bash session in Console 2.

我通常将驱动器安装到文件系统,然后必须运行一个脚本来更改控制台 2 中 Git Bash 会话中的某些文件。

If you mount something to a given drive letter, say F: on the Windows file system, and then start the Git Bash session it will have it mapped. I can mount/unmount the F: drive and the session can still access /f/ without any issues. So, mount all the drives you will typically need to hit and then start the session and hopefully you don't need to restart your Git Bash too often.

如果您将某些内容挂载到给定的驱动器号,请在 Windows 文件系统上说 F:,然后启动 Git Bash 会话,它将对其进行映射。我可以挂载/卸载 F: 驱动器,会话仍然可以访问 /f/ 没有任何问题。因此,挂载您通常需要点击的所有驱动器,然后启动会话,希望您不需要过于频繁地重新启动 Git Bash。

回答by rakslice

I find that if I exit all currently running git bash sessions and then launch a new one, then I can access the new drive, e.g. X:, in the new bash session under /x/.

我发现如果我退出所有当前正在运行的 git bash 会话,然后启动一个新的会话,那么我可以访问新的驱动器,例如 X:,在/x/.

Even launching a new git bash session is not enough if there was already one running; I must exit the previous git bash sessions and then launch one for it to make the new drive letters available.

如果已经有一个正在运行的 git bash 会话,即使启动一个新的 git bash 会话也是不够的;我必须退出之前的 git bash 会话,然后为它启动一个以使新的驱动器号可用。

回答by Francis Liu

I found that if I set

我发现如果我设置

MSYS_WATCH_FSTAB=YesPlease

MSYS_WATCH_FSTAB=是的请

in my User Environment variables. Then everything worked.

在我的用户环境变量中。然后一切正常。