I would like to switch from Dropbox to the open source Sparkleshare. It uses git for the syncing and versioning. If say I had a 1GB file I deleted in my folder, it stays within the history of the local .git folder. But I would like to have this kind of heavy data on the server and not the client. How can I commit my repository and delete the local one with git? Many thanks!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Solution removing the history
git fetch --depth=1
to prune the old commits. This makes the old commits and their objects unreachable.git reflog expire --expire-unreachable=now --all
. To expire all old commits and their objectsgit gc --aggressive --prune=all
to remove the old objects
Specific solution just to remove the large file in the local history
- GitHub offer's Git Large File Storage, which stores large files always on the server and fetches them only on checkouts. Very easy to setup and use - in case your repository is on GitHub, bitbucket, or gitlab.
- git-annex - allows storing big files anywhere
Discussion: How do Git LFS and git-annex differ?