更改 Git Bash 上的默认位置

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

Changing default locations on Git Bash

gitgithubrepositorygit-bash

提问by Barry

I am new to using Git Bash and Git Hub. Upon installing Bash, I accepted all of the default settings. In doing so, made my network drive the default directory. I will be using this offline and need to change the default directory to my local drive. I have tried to change the location path of GitBash to the local drive but did this did not work. How can I change this? Also, is there any alterations that need to be made to the GitHub account?

我是使用 Git Bash 和 Git Hub 的新手。安装 Bash 后,我接受了所有默认设置。这样做,使我的网络驱动器成为默认目录。我将离线使用它,需要将默认目录更改为我的本地驱动器。我试图将 GitBash 的位置路径更改为本地驱动器,但这并没有奏效。我怎样才能改变这个?另外,是否需要对 GitHub 帐户进行任何更改?

回答by Piotr Berebecki

In my case I had to take the following steps to change the default startup directory of the Git Bash in Windows:

就我而言,我必须采取以下步骤来更改 Windows 中 Git Bash 的默认启动目录:

1)Right click on the Git Bash icon in your Windows Start menu and select Properties. In Windows 10 you may have to right click on Git Bash -> More -> Open file location -> Right click on the shortcut -> Properties

2)In the Start infield, paste the path to your desired folder, e.g. D:\git.

3)Remove --cd-to-homefrom the Targetfield.

1)右键单击 Windows 开始菜单中的 Git Bash 图标,然后选择属性。在 Windows 10 中,您可能需要右键单击 Git Bash -> 更多 -> 打开文件位置 -> 右键单击​​快捷方式 -> 属性

2)在该Start in字段中,将路径粘贴到所需文件夹,例如D:\git.

3)--cd-to-homeTarget现场移走。

回答by Drew Noakes

You can modify the shortcut to Git Bash in order to specify the starting directory. This is discussed here.

您可以修改 Git Bash 的快捷方式以指定起始目录。这在这里讨论。

Alternatively you can create a file called .bashrcin your home directory. That script is executed when the shell starts (rc stands for run-commands), so you can make that file cdinto whatever directory you like.

或者,您可以创建一个.bashrc在您的主目录中调用的文件。该脚本在 shell 启动时执行(rc 代表运行命令),因此您可以将该文件cd放入您喜欢的任何目录中。

回答by Estuardolh

You can also do it from CMD:

您也可以从 CMD 执行此操作:

start /D "path_target_on_windows_here" git_bash_path\git-bash.exe

It is useful for configuring a shortcut command on Notepad++ :]

在 Notepad++ 上配置快捷命令很有用 :]

回答by macchiavalley