Berkay
Berkay

Reputation: 1068

Is there a way to ignore a specific file for pulls meanwhile the file is in the repository?

I want to add a large file (e.g. a model) to my Git repository, to make sure it will not be lost in somewhere, but when other people call git pull, the file should not be pulled.

I have checked many sources, but none of them solved my problem. Also tried to manipulate .gitignore, but still, no solution.

To clarify: Now, working on a project, for just a part of it, a model was needed to be used. Since it is no longer in usage, but in future there might be some scenarios using it, I need the model be on the repository(size: 606 MB). In the future, whoever needs to use it, should be able to get it from the repository. Otherwise, it is not related the main flow of the project, just an issue is related with the model. Except the person will work in that mentioned issue, people do not need the model to be pulled with repository. That was the motivation of this question.

Upvotes: 0

Views: 100

Answers (1)

sbat
sbat

Reputation: 1888

There is no straightforward and "git-native" way to address your requirement. Git is distributed version control system, its normal mode of operation is to have full repo history for each repo clone.

Besides, Git commits are efficiently stored snapshots of the entire project file tree (see this chapter of the Git book for details https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain). There's no ease way to pull specific files only.

You have a few options:

  1. Do not do commit this model to GIT. Put it elsewhere and link it from your git repository somehow. For example, with Github you can use https://help.github.com/en/github/managing-large-files/distributing-large-binaries. Or just put it to your team cloud disk and link from the repo readme file. While this may seem like "low tech" approach, I think it works best in your scenario.

  2. Use Git LFS. https://git-lfs.github.com/ With Git LFS main repo only holds "links" to the large files, and you can have granular control over what individual users want to pull. That being said, it only worths it if there many files like that and/or you want to maintain their history accurately in the context of your entire repository. For just one file that never changes GitLFS team process overhead and learning curve will not worth the benefits in my opinion.

  3. Just create separate Git repo for your model. 600MB is definitely larger than normal file size for Git, and you may easily hit the limits of git hostings like GitHub. But you will probably find that local Git repo of this size peforms ok.

Upvotes: 5

Related Questions