0

I can't seem to run "git add -e" in either Powershell or Git Bash without getting errors. Here are the file (test3.html) contents in question:

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

Note that there is a carriage return at the last line.

Now, I run the following commands and receive the respective output from my local git repo:

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

And here is what appears after entering the "git add -e" command in notepad:

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>

There is a carriage return after the last line. The file was originally written with notepad++ in UTF-8 encoding.

As soon as I close notepad, I receive these errors:

error: patch failed: test3.html:1

error: test3.html: patch does not apply

Question: Why am I getting these errors, especially if I haven't changed a thing with ADD_EDIT.patch?

I've tried more complex flows where I would split the changes into separate hunks and decide which changes I wanted to commit. Similar results would occur. And, if I can't get even the most simple flow to work, then what's the point...

My reasoning behind this is to become more acquainted with Git since I'm new to it. I've been reading https://git-scm.com/docs/git-add and have been trying to follow along each option.

Any help, suggestions, or references to other posts that I might have missed are all greatly appreciated.

EDIT:

Here is how my configuration looks like:

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
  • 1
    How have you configured your line ending settings? Have you followed the advice at https://help.github.com/articles/dealing-with-line-endings/ ? – Edward Thomson Aug 23 '16 at 19:41
  • Thank you for the link. Unfortunately, after changing autocrlf to true or input I get the same thing: error: patch failed: test3.html:1 error: test3.html: patch does not apply fatal: Could not apply '.git/ADD_EDIT.patch' –  Aug 23 '16 at 20:44
  • I believe the reason you're getting this particular problem is because of the unix2dos and dos2unix commands being run after you attempt to edit the patch with `add -e` because what you generate in the editor doesn't match line endings with what those utilities are converting. `git add .` should work fine or running the line ending converters before you manually edit the patch. Could you share this file in a repository so I can test? – Jeff Puckett Aug 24 '16 at 01:25
  • @JeffPuckettII Interesting point. I do have to mention though that StackOverflow seemed to have automatically formatted the HTML. I removed the whitespace so that the HTML looks exactly like what I have in the file. I made the remote repository public so anyone is free to clone it: https://bitbucket.org/Mister0wl/using-git-with-a-gui –  Aug 24 '16 at 02:25

0 Answers0