Tip:
Highlight text to annotate it
X
[GIT MERGE 2013]
Hi there, I'm Roberto Tyley.
I work at The Guardian in the UK
and I wrote a tool called the BFG,
which is like a simpler, faster,
alternative to git-filter-branch.
Basically, addressing the problem of you
having unwanted crap in your Git history
that you want to get rid of,
that you can't get rid of
with a simple rebase because it
sort of pervades your entire project.
Yeah, so, it's a faster and simpler
alternative to git-filter-branch,
getting rid of unwanted things.
So, for instance, big files that might
make your repo really large to download
or passwords, maybe you wanna
share your repository on an external
hosting provider and you don't really want
everyone to see your old passwords,
even though, obviously,
you should've changed them-
so are we going with VGA?
Cool! Old style.
This is why I cover think path
because you know, they still have
VGA connectors. Is that gonna work?
Ok, so who has seen the video of the BFG?
Anyone? We've got some people at the back there.
Hey! Hi there! Ok, well seeing as
not everyone put their hands up,
I'm gonna play you the video.
So, one of the main compelling points
is that it is faster
and so to demonstrate that [laughing]
I put it onto a Raspberry Pi,
which is like a 25 pound computer,
very cheap computer, I have one here.
You see that? The BFG's command was
substantially simpler and there's this
little 700 megahertz device, compared
with like a nice big Quad Core Mac,
which is, you know, a nice computer.
And so they set off and look there,
the filter branch starts off with a major lead.
That's pretty good. And there's the BFG
running the backgrounds, that's a little
screen showing what the Raspberry Pi's
up to. Ahh but, the BFG is catching up
even though it's running on this.
Yeah, and as we speed up even faster
we can see that- wow, the BFG's like
totally taking the lead here.
It's like 41,000 commits and
[exhaling loudly] updating the rest, slowest part.
So that took 25 minutes on
that bit of hardware, this bit of hardware.
And so the end results,
the Mac took 45 minutes.
BFG took 25 minutes on the Raspberry Pi.
And if you have a regular
bit of hardware, maybe not this.
Then, it'll take a minute or so.
And, you know, if you have like a gigantic repository
you might have an overnight job
on your hands, especially if you're
doing something complicated.
So, I'm just gonna show you
like a few things the BFG makes easy.
Well, not that...
Anyway, so removing a file,
that's how you do it with the BFG.
Delete the right file.
With git-filter-branch that's pretty much
a standard command, like-
I mean, I know that all of the options,
it's a great chainsaw, but for the
specific task that a lot of people
want to use git-filter-branch for,
which is removing a lot of history,
then, probably stuff like that is easier.
It's just gonna delete every copy
of a file with that name that it can find
and you can use globs and regexes
and stuff if you wanna.
Now, supposing you have massive files
clogging up your repo, then that is how you do it
and maybe git-filter-branch isn't
the best tool for doing that,
I'm not sure but I've never really found
an answer that was shorter than massive
Python bash script or whatever.
And then, if you wanna remove
a bunch of passwords, just put a bunch
of those passwords into your file
and run it against the repo.
Or you could do sed
in the git-filter-branch.
So, it's just a bit easier and
you can use wildcards and
substitutions if you want to.
Alright yeah, treats you like a
reformed alcoholic in that it is not gonna play
with your latest commit.
Alright? That's like a principle that
you're supposed to be clear, tidying up
your current history. I'm just gonna
tidy up- your current commit.
I'm gonna tidy your history,
all this stuff in the past.
And so if you run the BFG
and it turns out you're trying
to delete passwords, it says,
"Oh, there's actually still passwords
like this in your current commit.
Maybe you should clean that out
before we continue 'cause
I'm not gonna touch them."
So you're a reformed alcoholic,
someone who's made mistakes in the past
but now you've cleaned up your act.
And, oh yeah, and this is just a little
nice tweak, so your commit messages
might reference other commits
and the BFG will fix those commit messages
if the commit ID resolves to something
that it knows and it will just say,
"Ah, this was formerly that commit."
And so, hopefully it's a nice friendly
way of cleaning out your history.
We've used it a lot at The Guardian,
it's been used in UK governments,
on some of their repos and various places.
So, it's relatively reliable.
It's built on Jgits,
it's written in Scala,
so you can script it if you want to
in any JVM language that you like,
if you like any JVM language.
[laughing] Ok, alright so that's it.
Thanks very much.
[applause]
[GIT MERGE 2013]