Windows 文件资源管理器,在上下文菜单中添加克隆剪贴板内容

问题描述 投票:0回答:1

另请参阅我的运行 Powershell

我的尝试是实施以下工作流程

  • 在 GitHub 或任何其他存储库服务器中将链接复制到存储库
  • 在 Windows 文件资源管理器中右键单击文件夹,例如
    D:\Projects
  • 选择“克隆”以克隆该文件夹中复制的存储库

我将其添加到注册表中

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\git-clone]
@="Clone here"

[HKEY_CLASSES_ROOT\Folder\shell\git-clone\command]
@="Powershell -NoProfile -Command \"git clone $(Get-Clipboard)\""

这确实会在上下文菜单中添加“克隆此处”,并且它会克隆,但不是在右键单击的目录中,而是在其父目录中。

如何在右键单击的目录中克隆存储库?

powershell registry git-clone
1个回答
0
投票

感谢@keithmiller提示我找到了解决方案

有效的命令是

Powershell -NoProfile -Command "Set-Location -LiteralPath '%V' ; git clone $(Get-Clipboard)"

可以使用以下

.reg
文件创建注册表项:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\git-clone]
@="Clone here"

[HKEY_CLASSES_ROOT\Directory\shell\git-clone\command]
@="Powershell -NoProfile -Command \"Set-Location -LiteralPath '%V' ; git clone $(Get-Clipboard)\""

我在这里使用目录分支而不是文件夹,因为它可能只适用于真实的文件目录。

© www.soinside.com 2019 - 2024. All rights reserved.