0
\$\begingroup\$

I would like to use Git for my Unity projects. I took the default .gitignore file that GitHub provides, but I noticed that it doesn't ignore the UserSettings folder. That wouldn't really be a big deal usually, but I noticed that the full project path is hardcoded in one of the files in that folder, specifically "UserSettings -> Layouts -> default-2021.dwlt" under "m_LastProjectPath".

I'm not a fan of that.

  • Should I put the UserSettings folder into the .gitignore as well, or maybe just "default-2021.dwlt"?
  • Is there perhaps a setting in Unity that removes m_LastProjectPath?
\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

Yes it should be ignored because, as you noticed, it's specific to each Unity user. You can find details behind the reasoning here: https://forum.unity.com/threads/whats-the-usersettings-directory.754436/

I don't know why the gitignore generated on the github website is out of date. I usually go directly to the source repository to get an up to date gitignore. As of today it contains the "UserSettings" folder. https://github.com/github/gitignore/blob/main/Unity.gitignore

Btw, if some folks need a little more detail on how to use it with Unity, I've written a blog post about that: https://crafty.creatiel.ca/blog/unity-gitignore-essentials

\$\endgroup\$
0
\$\begingroup\$

Yes, you can add this line to your .gitignore file to ignore /UserSettings folder:

/[Uu]ser[Ss]ettings/
\$\endgroup\$
3
  • \$\begingroup\$ Thanks, but this isn't really helpful. I already know how to add the folder to the .gitignore, that wasn't the point of my question. It's more about if I should add it to the .gitignore (pros and cons for example), and if the answer is "no", how to avoid having the full path inside the project files. \$\endgroup\$
    – Synn Ko
    Commented Jul 5, 2022 at 12:53
  • \$\begingroup\$ Yes, according to the documentation: docs.unity3d.com/2020.1/Documentation/Manual/… This folder should be ignored, it can contains some data that is per user (like perforce connection settings, layouts etc..). In older versions of Unity it was part of Library/EditorUserSettings.asset but Unity Technologies moved it to a separate folder since "people delete the library folder all the time" : forum.unity.com/threads/whats-the-usersettings-directory.754436/… \$\endgroup\$ Commented Jul 6, 2022 at 21:03
  • \$\begingroup\$ I see now what the problem was and where the confusion stemmed from... I was wondering why GitHub offered a seemingly outdated .gitignore for Unity projects, and it seems like GitHub actually messed up. When you create a new project on GitHub and pick the Unity .gitignore from the dropdown, like I did, it gives you an old version. However, if you click the "Get latest from" link in that same .gitignore file, you'll actually get the latest version of the .gitignore - one that has UserSettings in it. So for whatever reason, GitHub gave me the wrong .gitignore all this time... \$\endgroup\$
    – Synn Ko
    Commented Jul 7, 2022 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .