Windows上的git bash shell“您编辑的大块不适用” [英] git bash shell on Windows "Your edited hunk does not apply"

查看:131
本文介绍了Windows上的git bash shell“您编辑的大块不适用”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试使用命令时手动编辑hunks时,我遇到了一个非常令人沮丧的错误:

  git add -p 

我已经浏览了本网站上的许多现有问题,包括这是一个,和这一个



我正在尝试手动编辑大块文件,不更改到由git打开的文件以进行手动编辑,并且仍然收到错误您编辑的大块不适用。



我认为这可能与CRLF和LF EOL字符有关。我在Notepad ++中编辑,我可以看到我的所有行尾都是CRLF。我天真地试图将所有行结尾都改为LF,但无济于事。

我也可以看到所有的上下文行都有前导空格,所以这也不是问题。此外,我还有:

  git --global core.autocrlf 

设为 true



非常感谢。






编辑:根据VonC的回答,在我的具体情况下,权限+内容比较。这是否仍然意味着我不能这样做:

  git add -p 

如果它只是一个权限差异,我理解为什么这不是必要的,并且必须删除交互选项;但在这种情况下,是否还有一种方法可以继续执行交互操作 add

解决方案

首先,将 git --global core.autocrlf 设置为 false

然后克隆你的仓库,并检查 core.autocrlf 的值:

  cd / path / to / new / clone 
git config core.autocrlf

( no --global)



最后,再次尝试您的 git add -p 工作树)。



关于硬件管理,另请参阅意外的结果<


lock $ $ $ $ $ b

您编辑的大块不适用。



  diff --git a /< file-a> B /<文件-B个> 
index< short-hash-a> ..< short-hash-b> 100644
--- a /< file-a>
+++ b /< file-b>
<变更>

如果没有更改(仅限于权限),则在此情况下添加修补程序不会有道理:你只是 git add 文件(no -p



但如果有变化,OP提到的问题 git add --interactiveYour编辑过的大块不适用 仍然是引用。


I have a very frustrating error when trying to manually edit hunks while using the command:

git add -p

I have already looked through many of the existing questions on this site, including this one, and this one.

I am at the point where I try to manually edit a hunk, make no changes to the file opened by git for manual editing, and still getting the error "Your edited hunk does not apply".

I thought this might have to do with CRLF vs. LF EOL characters. I am editing in Notepad++, and I can see that all of my line endings are CRLF. I naively tried to change all the line endings to LF, but to no avail.

I can also see that all context lines have leading spaces, so that isn't the issue either. Furthermore, I have:

git --global core.autocrlf

set to true.

Any help is greatly appreciated.


Edit: According to VonC's answer, in my specific case I have a permission + content diff. Does this still mean I cannot do:

git add -p

If it were only a permission diff, I understand why this wouldn't be necessary, and the interactive option must be dropped; but in this case, is there a way to still do an interactive add?

解决方案

First, set git --global core.autocrlf to false.
Then clone again your repo, and check the value of core.autocrlf:

cd /path/to/new/clone
git config core.autocrlf

(no --global)

Finally, try again your git add -p (after reporting your modification in your new working tree).

Regarding hunk management, see also "Unexpected result in git-diff".


"Your edited hunk does not apply".

diff --git a/<file-a> b/<file-b> > 
index <short-hash-a>..<short-hash-b> 100644 
--- a/<file-a> 
+++ b/<file-b>
<changes>

If there was no changes (only in permission), adding a "patch" in that case does not make sense: you just git add the file (no -p)

But if there are changes, the question the OP mentioned "git add --interactive "Your edited hunk does not apply"" remains the reference.

这篇关于Windows上的git bash shell“您编辑的大块不适用”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆