Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: keep latest version of a file in repo, don't save history

Tags:

git

I have a repo that includes several binary files, which are rather big for git (up to several 100 MBs). I want to keep track of everything else via git and be able to clone that repo including those binaries. But i don't want the cumulative size of their blobs.

I can't keep the binaries outside the repo. A separate Git-LFS server is no option, since the "remote" is just a bare repo on a smb network share/external drive. The files already include their own versioning.

Is there any way I can push the newest version of those files to the remote, without saving the diff in history?

like image 987
Felix Groll Avatar asked Jan 16 '26 18:01

Felix Groll


1 Answers

Is there any way I can push the newest version of those files to the remote, without saving the diff in history

No diffs are saved in history. History consists entirely of commits, which are complete static snapshots of the state of the entire project (they are not diffs, or changes).

If the goal is to behave as if this file has no history, you would need to rewrite potentially all past commits to eliminate the file from them. That is not a tenable repeatable procedure going forward, but you could certainly do it once if you had to.

like image 64
matt Avatar answered Jan 19 '26 20:01

matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!