类似于sudo的msysGit命令

类似于sudo的msysGit命令

问题描述:

如果我们以管理员身份打开msysgit,则可以像使用root用户一样使用它.但是,没有管理员权限通常更容易打开.例如,要获得管理员特权,通常必须转到Windows资源管理器,开始"菜单/屏幕等,而不能从任务栏上执行此操作.有时,我懒得做所有这些事情,但是我想在Bash中获得管理员权限. Git Bash是否有类似sudo-或su的命令或脚本等?进入cmd.exePowerShell等,然后再执行runas之类的操作就可以了,如果没有其他要求的话.

If we open msysgit as administrator, we can use it as if we were root. However, it is often easier to open without administrator privileges. For example, for administrator privileges, you often have to go to Windows Explorer, the Start menu/screen, etc., and you can't do this from the taskbar. Sometimes, I'm too lazy to do all this, but I want to gain administrator privileges while in Bash. Is there a sudo- or su-like command or script, etc., for Git Bash? Going into cmd.exe, PowerShell, etc., then doing something like runas would work, if there's nothing else.

您无法从任务栏上完成

you can't do it from the taskbar

您可以:在单击图标的同时按 ctrl + shift ,它将以管理员身份打开.

You could though: press ctrl+shift while you are clicking on the icon, and it will open as Administrator.

注意: msysgit基于msys ,其中不包含任何类似sudo的命令.

Note: msysgit is based on msys, which doesn't include any sudo-like command.

评论 .com/users/3513273/aheryan> aheryan ,您可以在搜索时输入 ctrl + shift + enter 从开始菜单 中获取Git Bash:也将以管理员身份启动它.

As commented by aheryan, you can type ctrl+shift+enter when you're searching for Git Bash from the Start Menu: that will also launch it as Administrator.