0

So I want a bunch of files to be untracked and unchanged by Git. If I add them to gitignore, that doesn't remove them retroactively. If I remove them via this method, they disappear from all commits, but they actually disappear from my current working copy, too. I still need these files, I just don't need Git tracking them.

Any way to remove files as though they were there all along but not part of Git's "domain"?

For some reason, any of the usual methods for removing files leave the repo still just as large (~2.9GB) and it should be a couple of MB at most, if it were to only include my specific code.


FIXED!! Changing the memory settings in the config file allowed me to perform the git gc which is part of the procedure listed on this page. The settings I used were:

threads = 1
deltaCacheSize = 128m
windowMemory = 50m
Gazareth
  • 23
  • 4
  • How is one supposed to keep files that don't exist any longer? And by this I mean, what do you expect of working tree to be for anybody who would clone your project? – axelduch Jul 17 '15 at 18:12
  • I'm working alone, so this isn't something I'm accounting for. If I was working with others, I'd pay for a service, rather than using bitbucket's free <2GB per repo. – Gazareth Jul 17 '15 at 18:43
  • Okay, just for your information, git starts to suffer from too large repos I think around 1GB, so I'd recommend keeping your projects as light as can be anyways. – axelduch Jul 17 '15 at 18:45
  • Yeah, I would have preferred to have been doing that all along. I had no idea I had also included a bunch of binaries and stuff. It's really bummed me out. – Gazareth Jul 17 '15 at 19:06

2 Answers2

1
git rm -r --cached .
git add -A
git commit -am 'Removing ignored files'

The first command will un-track all files in your git repository. git rm -r --cached because of cached this file will be present in your local working copy and will be removed from repo.

The second command will then add all of the files in your git repository, except those that match rules in your .gitignore. Thus, we have un-tracked several files with just two commands.

Then the last command is to commit the changes, which will just be removed files. Another alternative solution is

//untrack committed files
git update–index –assume-unchanged fileName

This link will help you understand how Untrack files from git

Community
  • 1
  • 1
Novice
  • 458
  • 1
  • 6
  • 21
  • Thanks for the information. I did all this, and it seemed to work, but when I use "git count-objects" I still have the same amount, and the repo still takes up ~2.9GB even though according to my ignore list it should come to a couple of megabytes at most. – Gazareth Jul 17 '15 at 19:00
0

For git to stop tracking an already added file, you will have to remove the file from the index,

git rm --cached <file-path>
git commit

Add the file to your .gitignore and commit again. Git will no longer track the file.

pratZ
  • 3,078
  • 2
  • 20
  • 29