1

One of my colaborators uploaded a big data file to our repository. I don't want to download it each I pull or upload it everytime I push.

I followed advice form this question. So I ran:

git rm --cached <file>

After running commit again the file was not longer tracked, at least it said so in the ouput of:

git ls-tree -r main

However when I push it is still being uploaded.

I would like the file to stay in the repo for anyone to download if they wish, but not to be involved in push/pull.

Borut Flis
  • 15,715
  • 30
  • 92
  • 119
  • 2
    The two commands given do not unstage a file? If you want to untrack a file, remove it, and commit the removal. – evolutionxbox Nov 04 '21 at 10:49
  • 5
    It *is* removed from the staging area, and it *is* gone from the *next* commit. But this does not change any *existing* commit. Existing commits that have the large file, continue to have the large file. They will have that file as long as they (the commits) continue to exist. – torek Nov 04 '21 at 10:50
  • 3
    The big file existing in some past commit does not mean you'll have to download/upload anything on push/pull operations if the file doesn't change. if it's some sort of build result changing constantly, it should clearly not be versioned. – Romain Valeri Nov 04 '21 at 10:54
  • @torek interesting. I did run another commit after removing them from the staging area. – Borut Flis Nov 04 '21 at 11:30
  • 1
    @BorutFlis You can make that large file as git lfs file. Please refer to https://git-lfs.github.com/ – Jaymit Gupta Nov 04 '21 at 11:47

1 Answers1

1

Thanks for asking the question. You can try git lfs.Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers.You can then use git lfs clone <repo> to clone the repo without downloading the files again

Jaymit Gupta
  • 567
  • 5
  • 13
  • Thanks for the answer, but my problem is that the files are getting uploaded to github. How do I configure them not to update. – Borut Flis Nov 26 '21 at 18:48
  • @BorutFlis I think you should use .gitignore file, text file that tells Git which files or folders to ignore in a project. just create .gitignore in home directory of github repo – Jaymit Gupta Mar 22 '22 at 04:43