Paul Sinnema
Paul Sinnema

Reputation: 2792

Git with Visual Studio does strange things with my .csproj

Ok, this is a weird one and I have no clue how to get arround this problem. I'm using the following setup:

I been working with this for a while and for the first time something strange happens when I add or remove an image from a web project content/images directory.

Here are steps to reproduce this behavior in my project. Don't know if this also happens with other projects.

  1. We use 'development' as our development branche
  2. Create a new branche from 'development' named 'wake_on_lan'
  3. Check the branche has switched to 'wake_on_lan'

C:\Projects\P2G\P2G>git status
On branch wake_on_lan
nothing to commit, working tree clean

  1. Navigate to the Content/Images directory
  2. Click the wakeonlan.png and right click it and select 'Exclude from project'

enter image description here

git status On branch wake_on_lan Your branch is up to date with 'origin/wake_on_lan'.

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory)

    modified:   Sources/WUR.P2G.WEB/Wur.P2G.Web.csproj
    modified:   Sources/Wur.P2G.Web/Wur.P2G.Web.csproj

no changes added to commit (use "git add" and/or "git commit -a")

  1. Goto the Team Explorer. The change in .csproj is now visible.

enter image description here

  1. Commit the change and here it becomes weird. The change is committed but another change becomes visible to the same file (.csproj).

Git status tells the .csproj is modified (in red) but no changes are staged. Can't undo the change with VS. Can't checkout -- .csproj with git command line Gitkraken says there's a conflict but cant discard changes either

enter image description here

After this the only way I found so far to restore at least the project is to make a new clone from the repo.

I read somewhere I had to add *.csproj merge = union to the .gitattributes file but that makes no difference.

Upvotes: 0

Views: 551

Answers (1)

max630
max630

Reputation: 9238

It seems like you have the file duplicated in the repository with different cases. You can verify it by command git ls-tree -r HEAD.

You should remove one of them. Easiest way to do it is to use a Linux computer or some web interface. It should be possible at Windows somehow, but I cannot say how without trying it.

Upvotes: 1

Related Questions