1

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.

2
  • 1
    there is a similar question: stackoverflow.com/questions/1753070/… Commented Aug 12, 2021 at 22:13
  • use: git update-index --assume-unchanged <file-list> Commented Aug 12, 2021 at 22:14

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.