0

I have a Unity project and I've set it up to use Git.

However its only been kind of working. Its seeing some files and folders and committing them. But then its ignoring other files entirely.

For example, I have a ScriptableObjects folder. Any item I add in this folder NEVER appears in my version control as a new/changed file.

Other folders do work, but nothing in this subfolder.

This folder is not ignored in my .ignore.

I have also changed Unity to show Visible Meta Files for version control.

Its impossible for a new file to be un-tracked, and the folder its created it is not ignored.

I have never seen an issue like this before with version control. Do you have any ideas why my new files are not appearing in version control for some folders?

My ignore

Library/
Temp/
Obj/
Build/

# Autogenerated VS/MD solution and project files
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.csv#
*.*.csv#


# Unity3D generated meta files


# Unity3D Generated File On Crash Reports
sysinfo.txt

# Builds
*.apk
*.unitypackage

Update

Running the git ignore check on a new file produces the following

$ git check-ignore -v -- /c/Users/a/Desktop/proj/Assets/Resources/ScriptableObjects/Cards/Helmets/NewFile.asset "C:\Users\a\OneDrive\Documents\gitignore_global.txt":25:Assets/Resources/ScriptableObjects/ C:/Users/antho/Desktop/proj/Assets/Resources/ScriptableObjects/Cards/Helmets/NewFile.asset

random
  • 9,774
  • 10
  • 66
  • 83
Aggressor
  • 13,323
  • 24
  • 103
  • 182
  • Maybe some wildcard in your `.gitignore` file. Can you please post it. – Kay Jul 02 '16 at 05:17
  • Ill post it, but I also tried clearing the .git ignore entirely – Aggressor Jul 02 '16 at 05:17
  • Possible duplicate of [Source Tree Unity project Ghost files](http://stackoverflow.com/questions/35393928/source-tree-unity-project-ghost-files) – Fattie Jul 02 '16 at 13:09

1 Answers1

2

To easily check if a .gitignore is responsible, simply do (with a recent version of git):

git check-ignore -v -- path/to/ScriptableObjects/ 
git check-ignore -v -- path/to/ScriptableObjects/aNewFile 

That will display the right .gitignore (or .git/info/exclude) with the rule excluding that folder and its content.

Typically, an ignored file can still be added with a force (-f):

git add -f /path/to/ignored/file

In the OP's case:

C:\Users\a\OneDrive\Documents\gitignore_global.txt

Check your global config, as I mentioned before here.


The other possibility is that the folder and its files are part of a nested git repo, or a submodule.
Look for:

  • either a .git folder within your main repo
  • or a .gitmodules file in your main repo.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • When I run that command, nothing appears in the terminal. There is also no `.gitmodules` or `.git` files other than the one main one. – Aggressor Jul 02 '16 at 05:31
  • @Aggressor What version of git are you using? – VonC Jul 02 '16 at 05:32
  • 2.6.1 with SourceTree – Aggressor Jul 02 '16 at 05:32
  • @Aggressor Try 2.9.0 from command line, simply by unzippint (no need for setup) https://github.com/git-for-windows/git/releases/download/v2.9.0.windows.1/PortableGit-2.9.0-64-bit.7z.exe (it is an auto-extractible archive) anywhere you want (like C:\git2.9.0). That will leave your SourceTree setup untouched. – VonC Jul 02 '16 at 05:34
  • I admit this sounds too crazy to be true, but I can literally record a video to prove it haha. I will create file in the main `Assets` folder and it appears in the changed files log. If I add it to that subfolder, nothing appears! – Aggressor Jul 02 '16 at 05:34
  • @Aggressor Can you try and do a `git add -f path/to/Assets` – VonC Jul 02 '16 at 05:34
  • You have go to add a little flavor text to what you think is going on here XD – Aggressor Jul 02 '16 at 05:37
  • @Aggressor I mean, if Assets is somehow ignored, forcing git add should work: Can you try and do a `git add -f path/to/Assets`? – VonC Jul 02 '16 at 05:38
  • Interestingly enough though new files still arent appearing. They only appear now if I do the forced git add from the command you gave. Do you think we can identify the root cause? – Aggressor Jul 02 '16 at 05:39
  • @Aggressor That what a `git check-ignore -v -- aNewFile` (for a new file not yet added) would show. Can you try from a command line in git 2.9.0? – VonC Jul 02 '16 at 05:40
  • I added the output above. – Aggressor Jul 02 '16 at 05:46
  • @Aggressor Try the same command but: from within your main repo, and with a local *relative path: `cd C:\Users\a\Desktop\proj`, then `C:\git2.9.0\bin\git check-ignore -v -- Assets\Resources\ScriptableObjects\Cards\Helmets\NewFile.asset` – VonC Jul 02 '16 at 05:48
  • @Aggressor I have edited the answer, and added a link to http://stackoverflow.com/a/29161554/6309. – VonC Jul 02 '16 at 05:50
  • I do have git installed but I get an error when I try this command – Aggressor Jul 02 '16 at 05:50
  • @Aggressor no need for a bash, a regular CMD is enough – VonC Jul 02 '16 at 05:51
  • @Aggressor I have edited my previous comment, but again, I think you will find http://stackoverflow.com/a/29161554/6309 interesting. – VonC Jul 02 '16 at 05:53
  • Yup that was the issue. Out of NO where, this file I didn't create was somehow ignoring that entire subfolder. Thanks SourceTree. Wow what a hair scratcher. I can't upvote your help enough. Thank you so much. <3 <3! – Aggressor Jul 02 '16 at 05:55
  • 1
    @Aggressor You are welcome. That is one of the reason I rarely use a GUI, and always use the command-line ;) – VonC Jul 02 '16 at 05:56