-3

I have made a game 2 years ago for my presentation at school, but I didn't add .gitignore, nor cleaning up all the meta or extension files etc. This causes a problem that when I am trying to get back to the project and upgrading the game, the repo in question is filled with unnecessary native files from unity making the git repo becoming overpopulated, which also preventing me from further pushing any changes to it. I have added .gitignore now but its too late as the files are already uploaded to the git repo. There is no way I can find all the files one by one, checking if they are native/meta files and deleting them as there are 2000+ changes. Can anyone help me with this problem?

3 Answers3

0

Here you can see how to revert your repository to a previous state in git. If I get you right and the files got added by upgrading Unity the solution is quite simple: revert to before the upgrade.

If your repository is crowded already (since you did not ignore unnecessary data from the start) you'll have to delete the unnecessary data, commit the deletion and push it to your remote (see this post).

Thomas
  • 1,225
  • 7
  • 16
  • there are too many of them, and making sure which is which is going to take me a few days I guess... it is not as simple as that. Its very hard to find all the lib meta etc files in the repo and delete them one by one – Sugianto Wong Hock Chuan Nov 19 '20 at 06:59
  • For a computer it's trivial to find let's say "all .meta files in folder x". And Unity has a clearly specified project structure allowing for deletion of their native library files (lib and obj folder). Why is it so hard? – Thomas Nov 19 '20 at 07:09
0

You can try one of these:

  • Method 1: Make a new git, download the old Unity project to this new git. This time, before pushing to github, add the .gitignore file first.
  • Method 2: Stop tracking all the folders you want to ignore. How to stop tracking files

To stop tracking a file you need to remove it from the index. This can be achieved with this command.

git rm --cached <file>

Some git GUI programs can make this process easier. I suggest using SourceTree

By the way, DO NOT ignore .meta files, .meta files are needed to keep your project working. Unity uses those files to locate where your files are, which assets are referenced.

The majority of generated files that take up significant space are located only in the Library folder. You really don't have to worry about having too much work to do to ignore unnecessary files. If you use a git GUI program and you see unwanted files changes popping up, you can simply right click on them and stop tracking those files.

Trong Nguyen
  • 368
  • 2
  • 12
0

The easiest solution is to:

  • Add a .gitignore
  • Remove all cahed files with git rm -r --cached .
  • Add all the files again (with the .gitignore only the desired files will be added) with git add .
  • Commit the changes with git commit -m "Fixed untracked files"

Or simply use the all-in-one call:

git rm -r --cached . && git add . && git commit -am "Fixed untracked files"

Lotan
  • 4,078
  • 1
  • 12
  • 30