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

3
  • Maybe some wildcard in your .gitignore file. Can you please post it.
    – Kay
    Commented Jul 2, 2016 at 5:17
  • Ill post it, but I also tried clearing the .git ignore entirely
    – Aggressor
    Commented Jul 2, 2016 at 5:17
  • Possible duplicate of Source Tree Unity project Ghost files
    – Fattie
    Commented Jul 2, 2016 at 13:09

1 Answer 1

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.
18
  • 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
    Commented Jul 2, 2016 at 5:31
  • @Aggressor What version of git are you using?
    – VonC
    Commented Jul 2, 2016 at 5:32
  • 2.6.1 with SourceTree
    – Aggressor
    Commented Jul 2, 2016 at 5:32
  • @Aggressor Try 2.9.0 from command line, simply by unzippint (no need for setup) github.com/git-for-windows/git/releases/download/… (it is an auto-extractible archive) anywhere you want (like C:\git2.9.0). That will leave your SourceTree setup untouched.
    – VonC
    Commented Jul 2, 2016 at 5:34
  • 1
    @Aggressor You are welcome. That is one of the reason I rarely use a GUI, and always use the command-line ;)
    – VonC
    Commented Jul 2, 2016 at 5:56

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