Home > OS >  Initial Github Repository Commit For Unity Project, One Filename Too Long
Initial Github Repository Commit For Unity Project, One Filename Too Long

Time:01-10

I've created a new, currently empty Unity project (Unity version 2021.3.15f1) and have created a Github repository for it. I was having trouble with the initial commit--it kept throwing an error at me--so I tried following this guide https://unityatscale.com/unity-version-control-guide/how-to-setup-unity-project-on-github/ to see if I was doing anything specifically wrong. When I got to step 7/step 8, I got another error, so I decided to actually look through to see what was wrong. Almost every file threw up "LF will be replaced by CRLF the next time Git touches it", except for one:

error: open("ProjectName/Library/PackageCache/[email protected]/Runtime/VisualScripting.Core/Events/MessageListeners/MonoBehaviourMessageListeners/UnityOnControllerColliderHitMessageListener.cs.meta"): Filename too long error: unable to index file 'ProjectName/Library/PackageCache/[email protected]/Runtime/VisualScripting.Core/Events/MessageListeners/MonoBehaviourMessageListeners/UnityOnControllerColliderHitMessageListener.cs.meta' fatal: adding files failed

Once I unchecked that file from the commit, everything else committed just fine. This is the only file/change that won't commit. My question has a few parts.

  1. Do I need to commit this file?
  2. If I do need to commit this file, what happens if I don't?
  3. How do I fix this?

CodePudding user response:

No you should not commit this file. The whole Library folder isn't supposed to go into the repository, because it's generated by Unity.

What you need to do is: Add a .gitignore file to your repository and commit it (as a single file). From then on git will ignore the Library folder and a lot of other things. It will keep working with git much cleaner.

There are templates specifically for Unity, like here: https://github.com/github/gitignore/blob/main/Unity.gitignore

How .gitignore works is explained here (https://git-scm.com/docs/gitignore).

  • Related