Search code examples
gittortoisegit

File in bin folder still being versioned


I am using TortoiseGit and I am confused to why a file in the bin folder of my project (VS2015) is under version control. I would have thought this section in my .gitignore would have prevented the files in the bin folder from being versioned.

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
x64/
build/
bld/
[Bb]in/
[Oo]bj/

enter image description here


Solution

  • I do not know TortoiseGit well, however I would assume that some file in the bin folder has been committed before and was changed later on. The gitignore file only ignores files which are not part of the repository.

    To check if this is the case you would best have a look into the bin folder. There should be some files marked as modified, too (maybe you need to open some more folders which are marked as modified to find the files). If you have found such a file, do a git log on it (I assume this should be possible with TortoiseGit via the context menu of the file). You should then find one more commits which contain that file.

    There are two ways to handle that issue:

    Probably you don't want that file to be contained in your repository at all, e.g. because it is built by your build process and there is no need to version that file. In this case, you can remove that file(s) from your repository as described in this answer. Afterwards commit and from that on the bin folder should not be marked as modified anymore.

    If for some good reason you want to keep that file under version control but ignore your changes to it, you can mark it as "assume-unchanged" in your local repository. How to do that with TortoiseGit is described in this answer. Please be aware that this only works for your local repository.

    If you need a global solution to store that file in git but ignore changes to it, it would be important to know what sort of file it is and why you need to version control it but do not want to track changes to the file.