Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by Naserano · Jan 12, 2016 at 04:40 PM · unity 5gitmetadataversion control

.gitignore not ignoring Library. What's the correct way to do it?

First time Version Controlling, I'm using Bitbucket and SourceTree on Windows.

I created a new project, cloned it as a new repository, committed the changes. Then, I tried to gitignore the "Library" folder (since I've read I should) by using this: https://gist.github.com/thebeardphantom/982bab3b026571ab7970

Here's where I think I did something wrong:

I went to the project folder [User/Documents/MyProject] and created a text document named ".gitignore" with the content above. Having done that, I went back to SourceTree and committed the change.

Now, by doing that, should I expect the metadata files to get ignored? because they didn't. Actually, it had no effect on the repository. I tried different versions of ".gitignore" but all handed the same results. So my question is:

TL;DR: What is the correct way to .gitignore?

Comment
Add comment · Show 9
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bonfire-Boy · Jan 12, 2016 at 05:11 PM 1
Share

Was the Library folder already committed when you added it to the gitignore file? The ignore file can't make it ignore files that are already being tracked. When using git with Unity you should set up gitignore before the initial commit (or make sure you only commit stuff in ProjectSettings & Assets folders).

If this is the problem then it can be got around. See eg http://stackoverflow.com/questions/1274057/making-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore (but make sure you read it carefully)

avatar image Naserano Bonfire-Boy · Jan 13, 2016 at 03:46 AM 0
Share

Thanks, that appears to be the case! I removed the Library folder (following the instructions provided), but now everytime I make changes in Unity, the "Library" metadata still appears under "Unstaged Files", pending and waiting to be committed, is that normal?

avatar image Bonfire-Boy Naserano · Jan 13, 2016 at 08:14 AM 0
Share

Do mean just the Library.meta file? If so, it's probably still being tracked. It won't be removed from the index when you remove Library or Library/*.

Show more comments
avatar image saschandroid · Jan 13, 2016 at 09:03 AM 1
Share

Putting /Library into .gitignore should work.

Two things: - You wrote: ".gitignored" once in your question. Is this just a typo? - You said you created a text document named ".gitignore". It could be that this file has the extension ".txt" (windows) where it should have not (just ".gitignore"). So make sure Windows is showing you ALL file extensions and check if your file has one and remove it.

avatar image Naserano saschandroid · Jan 13, 2016 at 09:42 AM 0
Share

It's a typo, sorry.

".gitignore" does indeed have a ".txt" extension, and this was the very problem from the beginning. I changed its extension to just ".gitignore" by following these 4 steps: http://stackoverflow.com/a/12298593

"Library" is finally getting ignored. Thanks!

avatar image Bonfire-Boy saschandroid · Jan 13, 2016 at 09:46 AM 1
Share

If you follow the link to look at the .gitignore they're using, it does things the other way - removing everything then adding the things you do want. So it shouldn't be necessary to explicitly ignore the Library folder or its meta file.

Good point about checking that the basics are working though!

avatar image saschandroid Bonfire-Boy · Jan 13, 2016 at 09:53 AM 1
Share

I'm using TortoiseGit, so ignoring a folder (and it's content) is only one right click away :)

Btw: Unity creates only .meta files in my Assets folder, nowhere else (there is no Library.meta).

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Naserano · Jan 13, 2016 at 09:55 AM

Problem: .gitignore has no effect.

Reason: Its extension is ".txt" -> [.gitignore.txt]

Solution: Change it to ".gitignore" -> so it can become just [.gitignore]

This can be achieved in 3 simple steps:

  • Open your project folder [User/Documents/MyProject]

  • Hold SHIFT, right click anywhere in the folder you're in, then select Open command window here

  • Then rename the file in the command line, with: ren gitignore.txt .gitignore

Thanks to @BonfireBoy and @saschandroid

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image toast_sapper · Dec 28, 2016 at 09:43 PM 1
Share

I had this same problem and couldn't see it because Windows 10 was hiding the file extension ".txt", if it hadn't I would have spotted it immediately. Then it actually wouldn't allow me to rename the file to ".gitignore" saying that "A file name is required". Thanks, Windows. Thanks for making simple things difficult.

I opened GIT bash in the folder and ran

 mv .gitignore.txt .gitignore

and it resolved my problem.

avatar image CoderVinod · Feb 23, 2018 at 07:11 AM 0
Share

This solved my problem thanks.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

44 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Git - Ignore Library 2 Answers

How to fix /Library/ conflicts in GitHub repo for Unity project? 1 Answer

UnityYAMLMerge: File is not a valid text serialization YAML file 1 Answer

Build platform doesn't stick when using VCS (Git) 2 Answers

Unity and git - issue with constantly modified prefabs and scenes 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges