简体   繁体   English

Magit无法识别git存储库

[英]Magit not recognising git repositories

I'm currently trying to use Magit with Emacs 23.1 on Win7 64-bit but Magit does not recognise my git repositories. 我目前正在尝试在Win7 64位上将Magit与Emacs 23.1结合使用,但是Magit无法识别我的git存储库。 Please bear in mind I'm a complete Emacs newbie. 请记住,我是一名完整的Emacs新手。

I run the magit-status command and it asks for a directory containing the repo, which I obviously type in and then it just says every time I try: "There is no Git repository in "e:/path/to/directory". Create one? (y or n)" when there definitely is a repository in there. 我运行magit-status命令,它要求一个包含存储库的目录,我显然输入了该目录,然后每次我尝试时都说:“ e:/ path / to / directory中没有Git存储库。当肯定有一个存储库时,创建一个?(y或n)。

Has anybody else encountered this? 还有其他人遇到过吗? I've read that it could possibly be that the actual git.exe can't be found and I've tried messing around with my Path variable but nothing I do is allowing Magit to recognise my repositories. 我读到它可能是找不到实际的git.exe,并且我尝试弄乱我的Path变量,但是我没有做任何让Magit识别我的存储库的事情。 Any ideas? 有任何想法吗?

magit runs the following command to find the .git directory: magit运行以下命令以找到.git目录:

git rev-parse --git-dir

I would first try if Emacs really sees your git binary. 我首先尝试如果Emacs真的看到您的git二进制文件。 To do this, please open any file in your git repository in emacs. 为此,请在emacs中打开git存储库中的任何文件。 Next do Mx: shell-command and type the above git command in the prompt: git rev-parse --git-dir . 接下来执行Mx: shell-command并在提示符下输入上述git命令: git rev-parse --git-dir

As output you should get something like .git . 作为输出,您应该得到.git If you get 'git' is not recognized as an internal or external command, ... , then you need to make sure emacs/magit can find git. 如果您无法将'git' is not recognized as an internal or external command, ... ,则需要确保emacs / magit可以找到git。 You do this by either customizing magit-git-executable ( Mx: customize-variable ) and point it to the absolute path or by making sure the git directory is in the Windows PATH (if you use msysgit you have been asked during installation). 您可以通过自定义magit-git-executableMx: customize-variable )并将其指向绝对路径来进行此操作,或者通过确保git目录位于Windows PATH中来进行安装(如果使用msysgit ,则在安装过程中会被询问)。

Hope this helps! 希望这可以帮助!

Cheers, Daniel 干杯,丹尼尔

Found out the problem, it's the magit-escape-for-shell function that escape the executable which Windows can't handle. 发现了问题所在,是magit-escape-for-shell函数转义了Windows无法处理的可执行文件。 After checking the code of my previous installation, it's clear they've altered the code without changing the version, BAD! 在检查完我以前安装的代码后,很明显他们已经更改了代码,而没有更改版本BAD! Here's a patch that should fix that bug: 这是一个应该修复该错误的补丁:

--- magit.el.orig       2010-02-19 16:48:43.671875000 -0500
+++ magit.el    2010-02-19 16:49:30.078125000 -0500
@@ -320,7 +320,9 @@
                     prop val))

 (defun magit-escape-for-shell (str)
-  (concat "'" (replace-regexp-in-string "'" "'\\''" str) "'"))
+  (if (not (equal system-type 'windows-nt))
+      (concat "'" (replace-regexp-in-string "'" "'\\''" str) "'")
+    str))

 (defun magit-format-commit (commit format)
   (magit-git-string "log --max-count=1 --pretty=format:%s %s" format commit))

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

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