Heading image for post: Edge of Tomorrow, Explained in Git

Edge of Tomorrow, Explained in Git

Profile picture of Vic Ramon

Many people seemed to enjoy my recent post where I related X-Men: Days of Future Past to Git. So I've decided to do it again with Edge of Tomorrow. This is now the second installment in The Git Movie Series: Time Travel Movies Explained in Git.

SPOILER ALERT

Yeah, I'm about to discuss the entire movie.

In The Beginning

Major William Cage, played by Tom Cruise, meets with a British general in London. The general wants to send him to film the upcoming invasion on French beaches. Cage, not wanting to be anywhere near actual fighting, refuses and threatens to blackmail the general in order to get out of it. That really pisses the general off, so Cage is stripped of his rank and sent to a base at Heathrow Airport with orders to fight on the front lines of the invasion.

Cage gets minimal training on the exoskeleton suit and is dropped onto the beaches of France the next morning with the rest of the invasion force. It goes terribly. The mimics are ultrafast killing machines. In fact, I don't really know how any people are still alive at this point in the story. The mimics could have steamrolled the whole planet by now. Anyways...

$ git commit -m 'Wake up at the Heathrow base'
$ git commit -m 'Land on the beach'

The Magical Blue Blood

Cage gets obliterated, but right before he's about to die he grabs what looks like a Claymore and blows up one of the blue Alpha Mimics.

$ git commit -m 'Blow up an alpha mimic along with myself'

The mimic's magical blue blood (the power of Git) flows into Cage and he dies... only to immediately RESPAWN at the base at Heathrow Airport the day earlier with all of his memories intact.

Let's assume that Cage's memory is located in app/characters/cage/memories.yml. First let's do a soft reset on that last commit. That way we can isolate the memory file.

$ git reset head^

Git resets are soft by default, meaning that the files that are reset will still exist as unstaged files. With a hard reset the files would be removed entirely.

Now let's stash the memory file:

$ git add app/characters/cage/memories.yml
$ git stash

And now we want to reset hard all the way back to where Cage wakes up at the airport.

$ git reset --hard wake-up-at-heathrow-base-commit-id

And Cage still has his memories:

$ git stash pop

The Time Loop

The first time Cage respawns he is in a total daze. He goes back into battle and dies again.

$ git commit -m 'Land on the beach'
$ git commit -m 'Get killed by a mimic'

And now we repeat the soft reset, stash, hard reset, and stash pop:

$ git reset head^
$ git add app/characters/cage/memories.yml
$ git stash
$ git reset --hard wake-up-at-heathrow-base-commit-id
$ git stash pop

This same process happens over and over as Cage keeps dying.

Finding the Omega

Cage learns about the Omega from Dr. Carter, Rita's friend. Cage starts to have visions of the Omega in Bavaria, but when he goes to kill it there he finds out it's a trap. He narrowly escapes and is able to reset.

Cage and Rita go to retrieve the transponder. When Cage finally gets it and stabs it into himself, he obtains the power of GIT GREP. He can now search the world (the codebase) for the Omega. He discovers that it's located in the Louvre.

$ git grep omega
app/countries/france/paris/louvre/underground.yml: "omega"

Found the sneaky bugger.

Killing The Omega

After discovering the true location of the Omega, Cage gets in a car wreck and is knocked unconscious. He wakes up in a hospital where, to his horror, he sees that he has received a blood transfusion. He has now lost his ability to respawn (hard reset).

Cages sets out with Rita and the ragtag crew of misfits from Heathrow to kill the Omega. Only Cage and Rita make it inside the Louvre. Cage swims down to the Omega and blows it up. In an incredible stroke of luck, the blood from the Omega (git juice) enters Cage, giving him the ability to respawn one last time.

$ git commit -m 'Recruit ragtag gang'
$ git commit -m 'Kill the Omega'
$ git commit -m 'Cage and Rita die'

Let's check out a branch where we can save all this work we did to kill the Omega:

$ git checkout -b kill-omega

The Last Reset

This time Cage respawns at an even earlier time -- he's flying on a helicopter to London to meet with the general. But he soon finds out that the mimics have been destroyed, making this meeting rather unnecessary.

First checkout master and reset hard to the helicopter scene:

$ git checkout master
$ git reset --hard cage-gets-on-helicopter-commit-id

Now let's cherry-pick the single commit from the kill-omega branch where Cage killed the Omega:

$ git cherry-pick kill-the-omega-commit-id

This commit would also contain the most updated version of Cage's memories, so the codebase is now in the right spot.

Cage goes to find Rita, ending the movie with a big cheesy grin.

$ git commit -m 'Cage goes to talk to Rita'
$ git commit -m 'Everyone lives happily ever after'

More posts about Git Development

  • Adobe logo
  • Barnes and noble logo
  • Aetna logo
  • Vanderbilt university logo
  • Ericsson logo

We're proud to have launched hundreds of products for clients such as LensRentals.com, Engine Yard, Verisign, ParkWhiz, and Regions Bank, to name a few.

Let's talk about your project