简体   繁体   English

Git 建议,cygwin,WSL,PowerShell posh-git 模块

[英]Git recommendations, cygwin, WSL, PowerShell posh-git Module

I'm quite new to using git, so I'm not very knowledgeable, but have some questions, specifically about using git on Windows.我对使用 git 很陌生,所以我不是很了解,但有一些问题,特别是关于在 Windows 上使用 git。

  • Do I have to use git from https://git-scm.com/downloads or can I use other implementations of git?我必须使用 https ://git-scm.com/downloads 中的 git还是可以使用 git 的其他实现?
  • Alternatively, there is the posh-git PowerShell Module.或者,还有posh-git PowerShell 模块。 Can the Cmdlets / Functions in here do everything that git do and so make downloading and installing git?这里的 Cmdlet / 函数可以完成 git 所做的一切,从而下载和安装 git 吗?
  • For now, I'm installing via chocolatey cinst -y git installs also the cygwin.现在,我正在通过 Chocolatey cinst -y git安装 cygwin。 I have a problem with cygwin in that it's somewhat redundant these days, especially with things like WSL.我对 cygwin 有一个问题,因为这些天它有点多余,尤其是像 WSL 这样的东西。 Is it possible to just install the git commands without cygwin (I guess I just need the git.exe right?).是否可以在没有 cygwin 的情况下仅安装 git 命令(我想我只需要git.exe对吗?)。 I used to love cygwin and use it all the time, but in 2020, it does seem somewhat redundant, right?以前很喜欢cygwin,一直都在用,但是到了2020年,确实显得有些多余了对吧?
  • Alternatively, should I just install WSL and then go in there and sudo apt install git and then go back into Windows and just create a PowerShell function (using the wsl method to gain access to a command in the default WSL installation from Windows)? Alternatively, should I just install WSL and then go in there and sudo apt install git and then go back into Windows and just create a PowerShell function (using the wsl method to gain access to a command in the default WSL installation from Windows)? I think something like this should work:我认为这样的事情应该有效:
     function git { wsl git }

Advice from experts on which of the above would be most efficient and sensible would be appreciated.我们将不胜感激专家就上述哪种方法最有效和最明智的建议。

If you want a native Windows version of Git, the recommended option is Git for Windows, which you can download from that link or with Chocolatey.如果您想要 Git 的原生 Windows 版本,推荐的选项是 Git 用于 ZAEA23489CE3AA9B43406EBB2,您可以从该链接下载。 Because Git is designed for Unix, you do need a POSIX shell and a POSIX environment, which is shipped with Git for Windows. Because Git is designed for Unix, you do need a POSIX shell and a POSIX environment, which is shipped with Git for Windows. This is based off of MINGW, not Cygwin, but it is required so that programs written in shell, as well as things that invoke the shell like your editor, work.这是基于 MINGW,而不是 Cygwin,但它是必需的,以便用 shell 编写的程序以及像您的编辑器一样调用 shell 的东西工作。 posh-git doesn't change that. posh-git 不会改变这一点。

You can indeed use Git from WSL, but I would not recommend using it from a non-sh environment such as PowerShell.您确实可以使用 WSL 中的 Git,但我不建议在非 sh 环境中使用它,例如 PowerShell。 That's because a Unix Git will expect paths and such to be in the Unix format and won't accept any sort of Windows paths at all.这是因为 Unix Git 将期望路径等采用 Unix 格式,并且不会在所有路径中接受任何类型的 ZAEA23489CE3AAB94636。 So you can use WSL Git, but I strongly recommend using it from WSL and not PowerShell.所以你可以使用 WSL Git,但我强烈建议从 WSL 使用它,而不是 PowerShell。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM