0

我似乎无法在 Powershell 或 Git Bash 中运行“git add -e”而不会出错。以下是有问题的文件(test3.html)内容:

<!DOCTYPE html>
<html>
<head>
    <title>test</title>
</head>
<body>
    Hello
</body>
</html>

注意最后一行有回车。

现在,我运行以下命令并从本地 git 存储库接收相应的输出:

PS C:\repos\git-test> git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   test3.html

no changes added to commit (use "git add" and/or "git commit -a")
PS C:\repos\git-test> git add -e
unix2dos: converting file C:/repos/git-test/.git/ADD_EDIT.patch to DOS format...
dos2unix: converting file C:/repos/git-test/.git/ADD_EDIT.patch to Unix format...
error: patch failed: test3.html:1
error: test3.html: patch does not apply

这是在记事本中输入“git add -e”命令后出现的内容:

diff --git a/test3.html b/test3.html
index 1663e8c..03366ee 100644
--- a/test3.html
+++ b/test3.html
@@ -1,8 +1,9 @@
 <!DOCTYPE html>
 <html>
 <head>
-   <title></title>
+   <title>test</title>
 </head>
-   <div>
-   </div>
+<body>
+   Hello
+</body>
 </html>

最后一行后面有回车。该文件最初是用 UTF-8 编码的 notepad++ 编写的。

一旦我关闭记事本,我就会收到以下错误:

错误:补丁失败:test3.html:1

错误:test3.html:补丁不适用

问题:为什么我会收到这些错误,尤其是如果我没有使用 ADD_EDIT.patch 更改任何内容?

我已经尝试过更复杂的流程,我会将更改拆分为单独的块并决定我想要提交哪些更改。也会出现类似的结果。而且,如果我连最简单的流程都无法工作,那还有什么意义……

我这样做的原因是因为我是新手,所以要更加熟悉 Git。我一直在阅读https://git-scm.com/docs/git-add并一直在尝试遵循每个选项。

非常感谢我可能错过的任何帮助、建议或对其他帖子的引用。

编辑:

这是我的配置的样子:

PS C:\repos\git-test> git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=manager
user.name=Dash
user.email=some.email.address@gmail.com
core.editor=notepad
core.whitespace=trailing-space,space-before-tab
help.autocorrect=1
color.ui=auto
gpg.program=c:/Program Files (x86)/GNU/GnuPG/gpg2.exe
gui.recentrepo=C:/Users/Dash/repos/public-repo-test
apply.whitespace=fix
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.excludesfile=C:\repos\gitignore_global.txt
remote.origin.url=https://Mister0wl@bitbucket.org/Mister0wl/using-git-with-a-gui.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
apply.whitespace=nowarn
4

0 回答 0