I work regularly with 20-30 repos for various websites, many of which include some image or short video files. None of them are particularly large files, but the storage adds up after awhile! I would like to be able to just remove the images & videos from my local machine, but without deleting them from the remote repository. Is this possible? I've searched and found lots of answers about how to do the opposite (keep something in a local repo without it being in the remote one), but not the other way around.
Asked
Active
Viewed 38 times
1 Answers
2
Maybe the option --depth
of git fetch
can help you.
It converts your local repository into a shallow ("partial") repo that only holds files from a certain number of commits.
You cannot get rid of specific files this way, but you do not have to keep older files locally after a certain number of commits or time passed.
With --shallow-since
you can specify a date and exclude older data.
With --unshallow
you can return your repository to a complete state, removing all limitations.
For details see https://git-scm.com/docs/git-fetch and search for "depth" and "shallow" there.
The same option exists for git clone
.

Lynax
- 117
- 1
- 11
-
Shrinking the depth is a reasonable approach here. Careful with the word "partial" though, as Git is in the process of adding user-oriented support for what they are calling a "partial clone", which is different from a shallow clone. – torek Aug 13 '21 at 17:33