On Tuesday, 23 September 2014 07:28:34 UTC+2, Michael Mossey wrote:
> I'm very new to git, and so far I'm using it more like a system to back up
> files and transfer them from computer to computer, no branching or anything
> complicated yet. In one directory tree, most of my files are binary files,
> so git can't take advantage of storing only deltas and can't compress the
> files much. My database size has skyrocketed in the past month as a result.
> At the moment I really don't need versions of certain files or directories
> older than, say, 2 weeks. Is there a way to delete old history by that
> criteria (say anything before a specific date?).
As Magnus pointed it out, it sounds to me like there might be better tools
than git out there to achieve what you need (a quick Google returns this SO
post on backup software
and this Wikipedia page on versioning FS
<http://en.wikipedia.org/wiki/Versioning_file_system> for instance). That
said, to answer your question creating an orphan branch from a start point
*"S"* and rebasing what's between *"S"* and master onto it should do what
you're asking for -- especially if you're using it with *"no branching or
anything complicated yet"*.
*/!\ Note: this is a highly destructive operation, so you'll want to make
sure you backup your backup before trying this /!\*
First determine until which commit you wanna keep your history (everything
after that commit will be deleted if all goes well); you can use git-log
<http://git-scm.com/docs/git-log> with some fancy options (such as --until
or --since for instance) or whatever GUI client you're used to. Say the
branch you wanna delete history from is *master* and that the SHA1 of last
commit you wanna keep is *deadbeef*.
# Make sure your repo's clean
$ git status
# Create a new orphan branch called temp starting at deadbeef
$ git checkout --orphan temp deadbeef
# Create the inital commit from there
$ git commit -a
# Now rebase everything between deadbeef and master on top of temp
$ git rebase --onto temp deadbeef master
Your master branch's history should now have been rewritten to keep only
the commits you wanted. You can safely delete the temp branch (all it
contains is the initial commit) and you may have to run git-gc
<http://git-scm.com/docs/git-gc> manually to garbage-collect the now
unreferenced objects and actually get the disk space freed by the whole
If you get any conflicts during the rebase, you'll have to solve them
before continuing (see git-rebase <http://git-scm.com/docs/git-rebase> if
you're not familiar with how it works); but depending on how your tree
looks like chances are that you won't get any.
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.