如何在 Cygwin 中获得 Git 1.8?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14330050/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:01:11  来源:igfitidea点击:

How to get Git 1.8 in Cygwin?

gitcygwin

提问by mnaoumov

According to http://cygwin.com/packages/git/the latest available Cygwin package is 1.7.9-1.

根据http://cygwin.com/packages/git/最新可用的 Cygwin 包是 1.7.9-1。

I would like to update git to at least 1.8.0.

我想将 git 更新到至少 1.8.0。

Can I do this?

我可以这样做吗?

采纳答案by William Seiti Mizuta

To install git 1.8.0you need to compile the source code.

要安装,git 1.8.0您需要编译源代码。

You need to clone the git repository (git clone https://github.com/git/git.git), enter the git directory, change the current version to 1.8.0 or other version that you want (git checkout v.1.8.0) and type the following commands:

您需要克隆 git 存储库 ( git clone https://github.com/git/git.git),进入 git 目录,将当前版本更改为 1.8.0 或您想要的其他版本 ( git checkout v.1.8.0) 并键入以下命令:

make configure
./configure --prefix=/usr/local
make
make install

It will install git under /usr/localdirectory. For more information about git installation, like documentation, you can take a look in INSTALLfile localized in git repository root.

它将在/usr/local目录下安装git 。有关 git 安装的更多信息,如文档,您可以查看INSTALLgit 存储库根目录中本地化的文件。

回答by RedX

cygwinportshas many new versions of various tools

cygwinports有很多新版本的各种工具

At the time i write this it has 1.8.3.4

在我写这篇文章的时候它有 1.8.3.4

New, simplified installation instructions:

  • Use the latest Cygwin installers (at least version 2.829): setup-x86.exe for 32-bit, or setup-x86_64.exe for 64-bit. (Note that many packages have not yet been ported to x86_64.)
  • Launch setup-*.exe with the -K flag, e.g.:

    cygstart -- /path/to/setup-x86.exe -K http://cygwinports.org/ports.gpg

  • On Choose Installation Type page, select "Install from Internet".

  • On Choose Download Site(s) page, select a distro mirror, then enter ftp://ftp.cygwinports.org/pub/cygwinportsin the User URL field and press Add (making sure that both are highlighted).
    1. Alternatively, you can use a sourceware mirror, but if you do, you must use one hosted on a different server than your selected distro mirror.
  • Proceed with package selection and installation, making sure to install any indicated dependencies.

新的、简化的安装说明:

  • 使用最新的 Cygwin 安装程序(至少 2.829 版):setup-x86.exe 用于 32 位,或 setup-x86_64.exe 用于 64 位。(请注意,许多软件包尚未移植到 x86_64。)
  • 使用 -K 标志启动 setup-*.exe,例如:

    cygstart -- /path/to/setup-x86.exe -K http://cygwinports.org/ports.gpg

  • 在“选择安装类型”页面上,选择“从 Internet 安装”。

  • 在选择下载站点页面上,选择一个发行版镜像,然后在用户 URL 字段中输入ftp://ftp.cygwinports.org/pub/cygwinports并按添加(确保两者都突出显示)。
    1. 或者,您可以使用源软件镜像,但如果您这样做,则必须使用托管在与所选发行版镜像不同的服务器上的镜像。
  • 继续进行软件包选择和安装,确保安装任何指示的依赖项。

回答by Azif

I successfully installed git 1.8.4.474 by following these instructions; I'm running Windows 7 64 bits, cygwin version 1.7.22(0.268/5/3)

我按照这些说明成功安装了 git 1.8.4.474 ;我正在运行 Windows 7 64 位,cygwin 版本 1.7.22(0.268/5/3)

  1. Run the Cygwin setup utility and ensure you have the following packages installed:

    gcc
    autoconf
    curl
    libcurl-devel, required for http/https support 
                   (NOTE: this is an obsolete package, you will need to
                   uncheck "Hide obsolete packages" when selecting packages
                   to install)
    make
    libiconv
    python
    perl
    gettext
    

    You may need libiconv-devel and cygwin32-liviconv (see Marek's comment)

  2. Clone the Git sources with git clone https://github.com/git/git.git. A couple of notes on that with respect to Git configuration:

    Make sure core.autocrlf=false, otherwise you'll end up with DOS style line endings that cause the build to break.

    I also had a screwy http.sslcainfoproperty value; either unset it or point it to /usr/ssl/certs/ca-bundle.crt.

  3. From your newly cloned git repo, run the following commands:

    make configure
    ./configure
    make
    make install
    
  1. 运行 Cygwin 安装实用程序并确保安装了以下软件包:

    gcc
    autoconf
    curl
    libcurl-devel, required for http/https support 
                   (NOTE: this is an obsolete package, you will need to
                   uncheck "Hide obsolete packages" when selecting packages
                   to install)
    make
    libiconv
    python
    perl
    gettext
    

    您可能需要 libiconv-devel 和 cygwin32-liviconv(请参阅 Marek 的评论)

  2. 使用 git clone https://github.com/git/git.git克隆 Git 源。关于 Git 配置的几点说明:

    确保core.autocrlf=false,否则您最终会以 DOS 样式的行结尾导致构建中断。

    我也有一个奇怪的http.sslcainfo财产价值;要么取消设置,要么将其指向/usr/ssl/certs/ca-bundle.crt.

  3. 从您新克隆的 git 存储库中,运行以下命令:

    make configure
    ./configure
    make
    make install
    

回答by Reverse Tarzan

You're instructions didn't really work for me...

你的指示对我不起作用......

I followed these instructions (as far as making sure all the correct packages are installed)

我遵循了这些说明(只要确保安装了所有正确的软件包)

http://randomartifacts.blogspot.com/2013/04/compiling-git-on-cygwin.html

http://randomartifacts.blogspot.com/2013/04/compiling-git-on-cygwin.html

Modified the Makefile

修改了 Makefile

$ git diff Makefile
diff --git a/Makefile b/Makefile
index 3588ca1..90f337c 100644
--- a/Makefile
+++ b/Makefile
@@ -407,7 +407,7 @@ RPMBUILD = rpmbuild
 TCL_PATH = tclsh
 TCLTK_PATH = wish
 XGETTEXT = xgettext
-MSGFMT = msgfmt
+MSGFMT = msgfmt.py
 PTHREAD_LIBS = -lpthread
 PTHREAD_CFLAGS =
 GCOV = gcov

then

然后

make configure NO_MSGFMT_EXTENDED_OPTIONS=1
./configure
make NO_MSGFMT_EXTENDED_OPTIONS=1
make install NO_MSGFMT_EXTENDED_OPTIONS=1

Not sure if the param is needed for all the make commands, but this worked for me

不确定所有 make 命令是否都需要参数,但这对我有用

回答by Yorkwar

I got problem when doing "make install". The error message is:

执行“make install”时遇到问题。错误信息是:

install -d -m 755 '/usr/local/bin'
git: 'installation' is not a git command. See 'git --help'.
./install: line 4: Normally: command not found
./install: line 5: will: command not found
./install: line 6: to: command not found
./install: line 8: $: command not found
./install: line 11: syntax error near unexpected token .'
./install: line 11:
(or prefix=/usr/local, of course). Just like any program suite'

install -d -m 755 '/usr/local/bin'
git: 'installation' 不是 git 命令。参见'git --help'。
./install: line 4: 通常: command not found
./install: line 5: will: command not found
./install: line 6: to: command not found
./install: line 8: $: command not found
./安装:第 11 行:意外标记附近的语法错误(当然,或 prefix=/usr/local)。就像任何程序套件一样' .'
./install: line 11:

This is due to the case insensitivity of Windows OS if you have "./" in your PATH. Cygwin use the INSTALL file in the git source tree instead of /usr/bin/install. We have to rename some "INSTALL" files in the source tree to other file name. This is mentioned by http://zengrong.net/post/1817.htm

这是由于 Windows 操作系统不区分大小写,如果您的 PATH 中有“./”。Cygwin 使用 git 源代码树中的 INSTALL 文件而不是 /usr/bin/install。我们必须将源树中的一些“安装”文件重命名为其他文件名。这是http://zengrong.net/post/1817.htm提到的

回答by M.M

I had a problem doing this that took me an hour to debug, so am posting an answer in case anyone else comes here looking.

我在做这件事时遇到了一个问题,我花了一个小时来调试,所以我发布了一个答案,以防其他人来这里寻找。

Actually it is the same cause as Yorkwar's, but different errors.

实际上它与Yorkwar的原因相同,但错误不同。

Everything goes fine until make installoutputs:

一切顺利,直到make install输出:

$ make install
    GEN perl/PM.stamp
    SUBDIR gitweb
    SUBDIR ../
make[2]: 'GIT-VERSION-FILE' is up to date.
    GEN git-instaweb
    BUILTIN all
    SUBDIR git-gui
    SUBDIR gitk-git
    SUBDIR perl
    SUBDIR templates
install -d -m 755 '/usr/local/bin'
make: execvp: install: Permission denied
Makefile:2342: recipe for target 'install' failed
make: *** [install] Error 127

After a lot of mucking with UAC, setuid, icacls, ownership etc. , I found via stracethat the actual problem is that when executing install: since I have ./in my PATH, and Windows is case-insensitive, it tries to execute INSTALL, which is a textfile that does not have the xbit set. So the "Permission denied" refers to the fact that xis not set on this file.

在对 UAC、setuid、icacls、所有权等进行了大量处理之后,我发现strace实际问题是在执行时install:因为我./在我的PATH和 Windows 中不区分大小写,它尝试执行INSTALL,这是一个文本文件没有x设置位。所以“权限被拒绝”是指x没有在这个文件上设置的事实。

@Yorkwar fixed this by renaming all the INSTALLfiles, however another option is to edit Makefileand replace

@Yorkwar 通过重命名所有INSTALL文件来解决此问题,但是另一种选择是编辑Makefile和替换

INSTALL = install

with

INSTALL = /usr/bin/install

I'm using cygwin 32-bit in Windows 7 64-bit (installed it before cygwin64 came out and haven't bothered to upgrade). Successfully built and install git version 2.0.0.rc4.dirtywhich was the result of git clone https://github.com/git/git.git.

我在 Windows 7 64 位中使用 cygwin 32 位(在 cygwin64 出现之前安装它并且没有费心升级)。成功构建和安装git version 2.0.0.rc4.dirty,这是git clone https://github.com/git/git.git.

回答by Gerrit Brouwer

You can install the latest version for the Windows platform from git-scm.com/download/win.

您可以从git-scm.com/download/win安装适用于 Windows 平台的最新版本。

Add the following to your ~/.profile:

将以下内容添加到您的~/.profile:

export PATH=$PATH:`cygpath 'C:\Program Files (x86)\Git\bin'`

I use this git client from both SourceTree and cygwinin combination with a Gerrit/SSH server and did not run into any problem yet.

我使用 SourceTree 中的这个 git 客户端,并cygwin结合 Gerrit/SSH 服务器使用,但还没有遇到任何问题。