0

I have Visual Studio solution. I renamed 1 file in the solution: It was CartCreated and now it is BinTypeCreated. After renaming Visual Studio highlights this file as ignored: enter image description here

Git shows that file CartCreated was removed, but doesn't show that file BinTypeCreated was added (as it does usually):

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

    deleted:    Src/xxx.M2/Bin/CartCreated.cs
    modified:   src/xxx.M2/xxx.M2.csproj

According to .gitignore - file shouldn't be ignored. I tried to give different name to that file - it doesn't help. I tried to search the answer - but usually the answer is - check .gitignore.

  • How to force git to track renamed file?
  • Why VisualStudio added red point near to file name?

1 Answer 1

1

Looks like the problem related to the fact that folder name is "Bin" - which is standart git ignore thing.

  • To force git to track renamed file, we need to exlcude the target file from .gitignore. To solve the problem is just added exception to .gitignore, so now it looks like:

...
[Bb]in
...
!Src/xxx/Bin
...

  • Visual Studio 2015 marked the file as 'ignored' just because it can read git settings and in a some way cooperates with Git (also it can create empty repository etc.)
2
  • 1
    A couple things: First, excluding Bin/ is not a git standard. It is a VisualStudio standard (regardless of which VCS is used). The other thing is, you may want to think about whether including the bin/ directory is the right solution. It is if Bin/ is a source folder... which I think it might be here, but that's contrary to convention with VisualStudio so you might want to revisit it. If build products are placed in Bin/ then you still probably want those excluded, so you'd want a more specific rule (!Bin/*.cs maybe) or to force-add specific files and not use an exception rule Commented Sep 19, 2017 at 16:53
  • Thanks. Good point about "git ignore standart", i agree that it is not a git standart, but GitExtensions provides ignoring patterns, so i think it is "GitExtensions" standart too. Commented Sep 19, 2017 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.