The Plot of “Back to the Future” in 10 Git Concepts

October 21, 2015 is approaching– the “future” in Back to the Future Part II. And while Marty McFly’s style of time travel is still science fiction, software developers engage in a sort of their own time travel everyday: git source control.

For fun, here’s the plot of the Back to the Future series, as 10 git concepts!

Doc from the future

“It’s your commits, Marty! Something’s got to be done about your commits!”

1. Fast-forward merge

Einstein the dog becomes the first time traveler by doing a git merge and fast-forwarding one commit.

Einstein the dog just did a `git pull` and fast-forwarded one minute.

fast-forward-merge

2. Checkout a previous commit

Marty then goes back in time by doing a git checkout of a previous commit, made on November 5, 1955.

Delorean

checkout previous commit

Of course, if you git checkout a previous commit, that inevitably leads to…

3. Detached HEAD

Marty's brother: please fix these merge conflicts ASAP, my HEAD is literally detached right now.

Marty’s brother: “Marty, please fix these merge conflicts ASAP, my HEAD is literally detached right now.”

detached_head

4. Pull Request Accepted

Marty refactors some code…

Marty and George McFly

This… is the legacy codebase I’m dealing with?

After resolving merge conflicts, Marty’s changes to the timeline are accepted. When he returns to 1985, his life with Jennifer is the same and better… with a new truck!

marty_jennifer_truck

pull request

5. Release branches

Doc, Marty, and Jennifer then checkout the release-2015 branch and try out flying cars and hoverboards, but also see an older, still insecure Marty manipulated into losing his job. Looks like they will want to make some changes before merging the release branch into master!

hoverboard

release branches

6. Rebasing

Unfortunately, Old Biff rebases the master branch of the whole hill-valley repo on top of a new 1955 commit that contains the sports almanac, just so he can include the features he wants.

Old Biff rebases everything on top of a new 1955 commit that contains the sports almanac

rebasing

7. Rebase Conflicts

However, Biff’s rebase causes a ton of conflicts when Marty and Doc return to a 1985 that is much different than what they expect.

biff's tower

How’d he get admin access, anyway?

rebase flow

http://image.slidesharecdn.com/gittutorial2-141014072059-conversion-gate02/95/git-tutorial-ii-27-638.jpg?cb=1413271537

8. Branch management

Doc and Marty figure out what happened, wishing everyone had just followed Git Flow. They now have to go all the way back to the first rebased commit, 5nov1955 again, to undo the conflicts.

Proper branch management would've saved Doc and Marty a lot of trouble.

Doc: “This is precisely why we create a branch for each feature, Marty!”

git flow

Gitflow example from https://www.atlassian.com/pt/git/workflows#!workflow-gitflow

9. Amending a commit

Doc and Marty are able to solve the rebase conflicts, but a lightning strike to the time machine sends Doc back to 1885, where he is killed by “Mad Dog” Tannen. To save him, Marty travels back to 1885, and he and Doc amend the commit where Doc was killed, then rebase everything on top of that (luckily, everything still works).

clock_photos

git commit --amend

https://www.atlassian.com/git/tutorials/rewriting-history/git-commit–amend

10. Code Reviews

Back in 1985, Jennifer wonders if her future with Marty has to be exactly what she witnessed on the release-2015 branch. Luckily, Marty has learned from his code reviews with Doc and resists being manipulated into a car race that would have resulted in an accident. They decide that their future is not yet committed to master, and to code the best future they can together.

marty_jennifer_ending

Thank you for reading and have an excellent “Back to the Future Day” on October 21, 2015!

Leave a Reply

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