简体   繁体   中英

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:

  • Visual Studio 2017 v15.6.7
  • Git v2.17.0.windows.1

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'

在此处输入图片说明

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.

在此处输入图片说明

  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

在此处输入图片说明

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM