Git-like time travel in Avengers: Endgame

Spoilers. Although this is kind of a dumb post – I suppose that my excitement took over my sense of logic when I wrote it.

We should take the time to realize that the entire plot of Endgame was started by a mouse.

Now that we’ve gotten that out of the way, let’s talk about why the many-worlds approach to time travel allows the plot to be simulated as if the Marvel universe were some kind of rough outline of a Git repository.

We start off with the deranged space cockroach Thanos snapping his fingers and making half the universal population disappear. (Marvel narrowly escapes answering the moral question of who dies and who is simply in “limbo.”) In Git terms, half our files are gone, but they are still Git objects since they are in the history. We are in HEAD right now, in the master branch. We should also note that the Infinity Stones are also gone.

Now we fast-forward to five years’ worth of commits into the future. Plot, blah blah blah. Then when time travel is discovered, the film check outs various commits simultaneously, each in different worktrees. They are all in detached HEAD state: the Avengers can look around and try to commit changes, but their commits will be lost if they hard reset back into master@HEAD. Eventually, they find the files they want in the respective revisions and move them back to HEAD. But the entire object is being moved, which disrupts the consistency of the repository because the object’s history between the point when it was taken and HEAD is unknown.

Then the stones are used to recover the missing portion of the universal population.

Suppose the detached HEAD states where Thanos uses Nebula to realize what is going on is designated as a full branch. Thanos tries to go into HEAD… initiating a merge. A merge conflict ensues. The master branch wins the merge conflict completely.

To preserve the repository’s consistency, the stones objects are returned to their points of origin on the history in the master branch.

However, there is one thing that is not consistent in the timeline: Cap went back in time to live his life, but by going back in time, there were probably a duplicate number of Steve Rogers in the history, and there are no guarantees that HEAD would have the aged Steve Rogers since going back in time is really checking out in detached HEAD state rather than hard-resetting. That’s definitely a plot hole.

1 thought on “Git-like time travel in Avengers: Endgame

  1. Apparently, last night I had a dream where it felt some sort of a revelation that Avengers might be git based. Then I woke up today morning and just wanted to check if anyone had a similar thought – and I found your post. It is funny to imagine that everything in life is pre-determined with multiple branches/timelines and time travel is just an ability to switch between different branches – whether in future or in past.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.