如何在 Windows 7 中更改 git shell 的启动目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18726981/
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
How to change git shell's start directory in windows 7
提问by user2565010
I downloaded and installed the programs offered by GitHub including Git Shell.
我下载并安装了 GitHub 提供的程序,包括 Git Shell。
The problem is that I want to set up the home directory of the Git Shell program to a custom one, but I don't know how to do that.
问题是我想将Git Shell程序的主目录设置为自定义的,但我不知道该怎么做。
I tried changing the "start in" field from the properties menu of the Git Shell shortcut but it didn't work.
我尝试从 Git Shell 快捷方式的属性菜单中更改“开始于”字段,但没有用。
Can anybody please give me some information on how to change the home directory of the Git Shell to a custom one?
任何人都可以给我一些有关如何将 Git Shell 的主目录更改为自定义主目录的信息吗?
回答by Honest Abe
- Right click on Git Shell
- Choose Properties
- Move to the end of the Target field
- Change
--open-shell
to--open-shell=c:\your_dir
- 右键单击 Git Shell
- 选择属性
- 移动到目标字段的末尾
- 更改
--open-shell
为--open-shell=c:\your_dir
回答by Piotr Perak
1.Open GitHub Windows client.
1.打开GitHub Windows客户端。
2.Click tools (at the top of the window) and select 'Options'.
2.单击工具(在窗口顶部)并选择“选项”。
3.There you will find 'default storage location'. This is where Git Shell starts when you run it.
3.在那里您会找到“默认存储位置”。这是运行 Git Shell 时启动的地方。
回答by lanierhall
When I use @ssmith's answer it opens up in the right directory but does not have any of the features of posh-git. When I open it up normally it say s posh-git in the title, when I add this configuration it just says powershell...
当我使用@ssmith 的答案时,它会在正确的目录中打开,但没有 posh-git 的任何功能。当我正常打开它时,它会在标题中显示 s posh-git,当我添加此配置时,它只显示 powershell ...
I figured it out, use/create the file
我想通了,使用/创建文件
C:\Users\yourUserName\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
C:\Users\yourUserName\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
(the default profile) and then add the line mentioned above
(默认配置文件)然后添加上面提到的行
Set-Location C:\Your\Start\Directory
设置位置 C:\Your\Start\Directory
回答by ssmith
According the article below (in the "Posh-Git and PowerShell" section) you should be able to create a Documents\WindowsPowerShell\GitHub.PowerShell_profile.ps1
file that will start when your GitHub PowerShell starts. In that file you can add the Set-Location c:\path\to\repo
command.
根据下面的文章(在“Posh-Git 和 PowerShell”部分),您应该能够创建一个Documents\WindowsPowerShell\GitHub.PowerShell_profile.ps1
文件,该文件将在您的 GitHub PowerShell 启动时启动。在该文件中,您可以添加Set-Location c:\path\to\repo
命令。
For what it's worth, in case anyone comes across this but has a Bash shell, adding the command cd /path/to/repo
to ~/.basrc should do the trick.
对于它的价值,如果有人遇到这个但有一个 Bash shell,将命令添加cd /path/to/repo
到 ~/.basrc 应该可以解决问题。
http://haacked.com/archive/2012/05/21/introducing-github-for-windows.aspx
http://haacked.com/archive/2012/05/21/introducing-github-for-windows.aspx
回答by jbooker
Piotr Perak directions are accurate. however, for newer versions, you have to update the "Clone Path".
Piotr Perak 方向准确。但是,对于较新的版本,您必须更新“克隆路径”。
- Launch GitHub for windows.
- 为 Windows 启动 GitHub。
- Click "Tools and Options" gear at top right > Options
- 单击右上角的“工具和选项”齿轮> 选项
- Change "Clone Path" to the directory you would like git to open at. Please see image below. Thank you.
- 将“克隆路径”更改为您希望 git 打开的目录。请看下图。谢谢你。
回答by Hyman
Other answers didn't work for me, and I am on Windows 10. So for those looking for another way I added a line to my ~/.bashrc: cd /c/myfoldername
其他答案对我不起作用,我在 Windows 10 上。所以对于那些寻找另一种方式的人,我在 ~/.bashrc 中添加了一行: cd /c/myfoldername
Works like a charm
奇迹般有效