6

So I know variants of this questions have been asked and answered before, so first I want to go through some of my own research to show you that I do not have a duplicate.

  1. The git ignore is not actually a .gitignore file: .gitignore is not working
    • My file is called .gitignore and I have set widows to show me the whole filename of all filetypes. (The file was called Unity.ignore, renaming it did not solve the issue)
  2. The .gitignore was added after tracking files, and you need to untrack them first. Like this: .gitignore not working in github for mac program
    • No, the .gitignore was added to an empty repo. Made sure to commit.
  3. The .gitignore file is not placed correctly.
    • Now i am not to savvy with Linux and bash, but I've been told to place it in root and I think that is what I have done here.

The first two are the main reasons I see people having problems with .gitignore files but that is not where I am having a problem. The last one i am 99% sure is also not the problem.

After telling git to ignore my Library and Temp folder, any files from temp and Library still shows up in the GitHub client for windows when preparing to commit: Linked image since Imgur is having problems

Edit: Same issue when viewing the repo in SmartGit

And my .gitignore file

# =============== #
# Unity generated #
# =============== #
[Tt]emp/
[Oo]bj/
[Bb]uild
/[Ll]ibrary/
sysinfo.txt
*.stackdump

# ============================================= #
# Visual Studio / MonoDevelop / Rider generated #
# ============================================= #
[Ee]xported[Oo]bj/
.vs/
/*.userprefs
/*.csproj
/*.pidb
/*.suo
/*.sln*
/*.user
/*.unityproj
/*.booproj
/.idea*/

# ============ #
# OS generated #
# ============ #
.DS_Store*
._*
.Spotlight-V100

Stack Overflow community, thank you in advance. This is driving me nuts.

I have been made aware that the problem had to do with that folders being created by unity and that somehow that messed up the order of ignoring/tracking and i am investigating.

Community
  • 1
  • 1
TheLemur
  • 99
  • 1
  • 9
  • Have you previously added Library and Temp folders to source control (by mistake) before adding them to `.gitignore`? Also, Did you try making a test by creating a new file (a txt file, for example), adding it to `.gitignore` and checking if it's being ignored? (you don't need to commit `.gitignore` to see it working) – Roberto Feb 28 '17 at 23:10
  • I tracked down the problem in the end it looks like. The index of the repo I had was not "fresh" but had tracked files that was a carryover from an earlier iteration of the same project. In the end it was in fact issue number 2. despite me thinking i had been careful to avid that. – TheLemur Mar 01 '17 at 00:20

4 Answers4

5

I have never used a .gitignore which is named Unity.gitignore. Maybe I am wrong but I think the file name has to be .gitignore literally i.e. without any suffix.

[Edit]:
You can check git's ignore rules by the following command:

git check-ignore -v MY_FILE_NAME

Another point to check is the .gitignore_global file, although I don't think this solves your problem.

Last not least Unix vs. Windows: Do you have the appropriate line endings, especially when working under Windows?

You can have a look at one of my Unity projects at GutHub for example https://github.com/kayy/BundleVersionChecker. This definitely works

Kay
  • 12,918
  • 4
  • 55
  • 77
  • That is odd, because that is how the file was generated by Git Hub when it asked what kind of .gitignore you need. Testing it out now ofc. Edit: No this did not solve the problem https://gyazo.com/87aba138a5ea117bea51483c447f5352 – TheLemur Feb 28 '17 at 20:58
  • Maybe this is to be avoid overwriting an existing _.gitignore_ writen by hand - just an assumption – Kay Feb 28 '17 at 21:02
  • Maybe :/ But it would seem strange to supply all users from git hub with a "faulty" .ignore file.... I must be doing something wrong but i just cant see it :/ – TheLemur Feb 28 '17 at 21:15
  • I just tried it out with a test repository. As soon as I rename my existing _.gitgnore_ to _Unity.gitignore_ it stops working. This was under Mac OS but I expect the same behaviour under Windows too. – Kay Feb 28 '17 at 21:18
  • Thanks for testing that out, but its a bit beside the point as I have also made the change on my end to no avail :/ – TheLemur Feb 28 '17 at 21:24
  • Having the ability to look at a project actually helped a bit. I think I am on the track of it now actually. Except I still don't know what the root of the problem is. Thank you! – TheLemur Feb 28 '17 at 22:07
3

The file cannot be called Unity.gitignore; it has to be called just .gitignore. Rename it to .gitignore and it'll take effect.

Haldean Brown
  • 12,411
  • 5
  • 43
  • 58
  • This does not appear to solve the problem: https://gyazo.com/87aba138a5ea117bea51483c447f5352 The file with the name Unity.gitignore was also the default .ignore file created by git hub when the repo was initially set up. – TheLemur Feb 28 '17 at 21:03
2

I tracked down the problem in the end and it looks like is was in fact issue number 2, despite me thinking i had been careful to avoid that. The index of the repository I had was not "fresh" but had tracked files that was a carryover from an earlier iteration of the same project.

The solution was to remove the .gitignore and untrack ALL files. I think as an alternative I could have just create a fresh repo and uploaded just the asset folder and project settings folder together with the .ignore file i already had.

So yeah, rubber-duck, sorry.

TheLemur
  • 99
  • 1
  • 9
0

Check your .gitignore file for unwanted text it may have, Always edit .gitignore file in Visual studio code instead of textedit or any other editor. Apart from this check for file extension as well.

Komal Gupta
  • 155
  • 5