Cache Staheli Cache Staheli - 10 days ago 7
Git Question

Unity files not being ignored properly by git

I'm working with Unity in a group, and because of what I've read in several places, we put the following lines into our

.gitignore


# =============== #
# Unity generated #
# =============== #
[Tt]emp/
[Oo]bj/
[Bb]uild
[Ll]ibrary/
sysinfo.txt
*.stackdump

# ============================================= #
# Visual Studio / MonoDevelop / Rider generated #
# ============================================= #
[Ee]xported[Oo]bj/
.vs/
/*.userprefs
/*.csproj
/*.pidb
/*.suo
/*.sln*
/*.user
/*.unityproj
/*.booproj
/.idea*/

# ============ #
# OS generated #
# ============ #
.DS_Store*
._*
.Spotlight-V100
.Trashes
ehthumbs.db
[Tt]humbs.db
[Dd]esktop.ini


When I clone the project, the working directory is clean, but as soon as I open this project in Unity, I see tons of files were marked as changed in
git status
:
git status

Why are these files being added even though they are in the
.gitignore
?

Answer

Were they by any chance added before you created the .gitignore file?

If so, then remove them:

git rm --cached [file]

After that make a new commit with the changes. That is it, they will be removed and untracked from then on.

Comments