admin管理员组文章数量:1128286
We have a repository with several large sql files, ranging from 100MB to 10GB in size.
Been trying to setup local cloning so we only download the sql file(s) that need changed and committed at any given time, instead of downloading all the sql files, even if we only need one.
I've been able to get close with the following commands. It works up until I commit my changes, at that point it downloads all the files in the current branch.
git clone --filter=blob:none --depth 1 -n --sparse <url>
cd <repoDir>
git sparse-checkout set <fileNeedingChangedAndCommitted>
git restore --staged .
git restore <fileNeedingChangedAndCommitted>
# At this point, the file I need to change is downloaded locally, ready for changes.
# Make changes to file.
git add <fileNeedingChangedAndCommitted>
git commit -m "test"
# At this point, all other files in current branch are downloaded, even if not changed.
I feel like this should be possible, but maybe I'm misunderstanding the concept of sparse-checkout or missing a step/detail.
Is there any way to download only the files you want to change, and then commit those changes without downloading every file in the current branch?
EDIT: From my testing and the chatter on this question, came to the conclusion that this isn't possible with Git. However, we decided to keep the SQL files in their own orphaned branches in the same repo, so they each have their own commit history/chain but are in the same repository for organization. This allows us to checkout only the branches/files we need at any given time, and make changes/commits without downloading all the blobs/hashes of the other sql files. This won't work for every situation, but solves our requirement for now :)
We have a repository with several large sql files, ranging from 100MB to 10GB in size.
Been trying to setup local cloning so we only download the sql file(s) that need changed and committed at any given time, instead of downloading all the sql files, even if we only need one.
I've been able to get close with the following commands. It works up until I commit my changes, at that point it downloads all the files in the current branch.
git clone --filter=blob:none --depth 1 -n --sparse <url>
cd <repoDir>
git sparse-checkout set <fileNeedingChangedAndCommitted>
git restore --staged .
git restore <fileNeedingChangedAndCommitted>
# At this point, the file I need to change is downloaded locally, ready for changes.
# Make changes to file.
git add <fileNeedingChangedAndCommitted>
git commit -m "test"
# At this point, all other files in current branch are downloaded, even if not changed.
I feel like this should be possible, but maybe I'm misunderstanding the concept of sparse-checkout or missing a step/detail.
Is there any way to download only the files you want to change, and then commit those changes without downloading every file in the current branch?
EDIT: From my testing and the chatter on this question, came to the conclusion that this isn't possible with Git. However, we decided to keep the SQL files in their own orphaned branches in the same repo, so they each have their own commit history/chain but are in the same repository for organization. This allows us to checkout only the branches/files we need at any given time, and make changes/commits without downloading all the blobs/hashes of the other sql files. This won't work for every situation, but solves our requirement for now :)
Share Improve this question edited 2 days ago Eschin Tenebrous asked Jan 8 at 19:32 Eschin TenebrousEschin Tenebrous 278 bronze badges 5 |1 Answer
Reset to default 1I feel like this should be possible, but maybe I'm misunderstanding the concept of sparse-checkout
The problem is not in sparse checkout, the problem is in --filter=blob:none
. This filter prevents downloading all object at the clone time but Git downloads the necessary objects later when they're accessed.
Is there any way to download only the files you want to change, and then commit those changes without downloading every file
Most probably no. Virtually Git stores a copy of the entire working tree in an every commit. I said "virtually" because technically Git does all its best to never store copies, instead it saves pointers to existing objects. To construct a commit Git needs all trees and blobs from the previous commit so that's what it downloads. With sparse checkout but without filter Git would have all necessary objects and wouldn't download anything; but everything must be pre-downloaded.
The bottom line: you can download and use locally as little as possible. But once you gonna commit Git will need all objects. So either you tolerate Git downloading required objects or allow Git to pre-download everything by removing filter: git clone --depth 1 -n --sparse <url>
本文标签: filterGit clone and download only the files that need changed and committedStack Overflow
版权声明:本文标题:filter - Git clone and download only the files that need changed and committed - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736691682a1947966.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
git commit --quiet
does not download all objects. One of the features of plaingit commit
is that you get a summary of the changes. But with--quiet
the summary does not have to be computed. – j6t Commented 2 days ago--quiet
a short bit ago, and the commit still caused all the unwanted blobs to download :( – Eschin Tenebrous Commented 2 days ago