如何为 Git for Windows 配置简单的上下文菜单?

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

我需要为不太习惯 Git 的用户提供一个very 简单的上下文菜单。 我首先调查了

TortoiseGit
,但这是开始的复杂方式。

所以我研究了设置自己的上下文菜单。我仍然需要 TortoiseGit 的状态图标,所以我只隐藏上下文菜单。

所以我在考虑添加这些菜单...

先决条件将是

  • Windows 版 Git
  • PowerShell 7.2.x
  • TortoiseGit(禁用上下文菜单)
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\Git Wrapper]
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\Git"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git]

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git\shell]

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git\shell\Add]
"Icon"="C:\\Program Files\\Git\\git-bash.exe"
"MUIVerb"="Git Add (Track all changes)"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git\shell\Add\command]
@="pwsh -windowstyle hidden -command $res = git add . 2>&1; [System.Windows.MessageBox]::Show($res,'Git for Windows',0,'Info')"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git\shell\Clone]
"Icon"="C:\\Program Files\\Git\\git-bash.exe"
"MUIVerb"="Git Clone (Remote Repo)"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git\shell\Clone\command]
@="pwsh -windowstyle normal -command $repo = Read-Host 'Enter remote URI'; $res = git clone $repo 2>&1; [System.Windows.MessageBox]::Show($res,'Git for Windows',0,'Info')"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git\shell\Commit]
"Icon"="C:\\Program Files\\Git\\git-bash.exe"
"MUIVerb"="Git Commit (Revision Message)"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git\shell\Commit\command]
@="pwsh -windowstyle hidden -command $res = git commit 2>&1; [System.Windows.MessageBox]::Show($res,'Git for Windows',0,'Info')"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git\shell\Init]
"Icon"="C:\\Program Files\\Git\\git-bash.exe"
"MUIVerb"="Git Init (Folder structure)"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git\shell\Init\command]
@="pwsh -windowstyle hidden -command $res = git init 2>&1; [System.Windows.MessageBox]::Show($res,'Git for Windows',0,'Info')"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git\shell\Sync]
"Icon"="C:\\Program Files\\Git\\git-bash.exe"
"MUIVerb"="Git Pull/Push (Sync Remote Repo)"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\Git\shell\Sync\command]
@="pwsh -windowstyle hidden -command git pull; $res = git push $repo 2>&1; [System.Windows.MessageBox]::Show($res,'Git for Windows',0,'Info')"

这就足够了吗,或者我缺少一些基本的东西?
我确实考虑稍后用更用户友好的基于 GUI 的 PowerShell 模块替换原始 PowerShell 输入/响应。

我确实认为我还需要简单的创建分支/将新分支推送到远程/切换分支/删除分支选项。

powershell contextmenu git-for-windows
© www.soinside.com 2019 - 2024. All rights reserved.