Connor Wyatt
Connor Wyatt

Reputation: 21

Git - Remove file from .git folder without removing it remotely

I have a repository for my website and I keep my photoshop .psd files in it which can be quite large (I have one that is 174mb large).

When I edit it it obviously uploads the whole thing again, which I'm not too bothered about because I only push it when I don't need to use the computer for a while.

The problem is though, I have a .git folder that is nearly 2gb because of all the previous versions.

I want to keep the old psd files on BitBucket as a backup but I want to get rid of them locally. Is this possible?

If not, I will delete them and back them up elsewhere.

Upvotes: 2

Views: 86

Answers (1)

Chris Maes
Chris Maes

Reputation: 37832

I think you just need a shallow clone. If you have pushed everything; you can just remove your local folder; and clone again with the --depth parameter:

git clone --depth=5 <repo-url>

This will only give you the last 5 commits from your repository; while at your remote you will still have the whole history. Off course this is valid for all your commits; not only for the ones related to your .psd files.

EDIT : off course removing your directory and then cloning it again is overkill; you can just remove your old history; but its less intuitive; you can get some inspiration here

Upvotes: 3

Related Questions