First a little context to the problem:
My work can be divided into two categories:
- Maintaining ASP.NET Web forms legacy projects
- Building new ASP.NET Core 2/3.1 projects
When maintaining the web forms legacy projects, I get often a Git error the last couple of months. The following error occurs when I try to stage/add parts of code through GitExtensions:
error: patch failed: [FileName].aspx.cs:[LineNumber]
error: [FileName].aspx.cs: patch does not apply
The message is added with some code where the actual patch fail occurs (see example later in this post).
As mentioned before, the error only occurs in the web forms projects and this is the only correlation I can find between the errors. It seems that the error occurs at random pieces of code in random files that I try to stage/add.
I use the following tools for source control:
- The most recent version of Git (2.25.0)
- The most recent version of Git Extensions (3.3.1.7897)
Repositories are hosted by Bitbucket and developing happens in the most recent version of Visual Studio Professional
I already tried the following to solve the error:
- Re-cloned all of my projects
- Reinstalled Git
- Reinstalled Git Extensions
- git: patch does not apply
In the example I tried to stage line 91 and 92. Then the error occurs as can be seen in the left part of the image. But when I stage line 182, everything is fine
I already looked with some colleagues what the problem could be. They also never encountered it and don't know how to solve it.
Oh yeah, a little disclaimer. This is my first post on SO. Please let me know if I didn't provide information in a desired or sufficient way so I can improve upcoming posts.
Kind regards
EDIT
The problem seems Git Extension related. I just installed Source Tree and there everything works fine.