O'Reilly logo
live online training icon Live Online training

Git Next Steps

Learn Git from the inside out to become a Git expert

Topic: Programming
Raju Gandhi

Sure, you already use Git. You’re familiar with Git’s staging area and how to commit your code. Maybe you’ve created feature branches and merged your code into your main integration branches. You’ve probably even tagged your code and sometimes leveraged the stash.

But there are times when you still find yourself in a Git mess. Ever committed your work to the wrong branch? Ever wondered what “detached HEAD” mode is and why it’s useful? Or what the difference is between branches and tags? And what’s a rebase anyway, and is it better to use than merges?

Expert Raju Gandhi shows you the trick to really “getting” Git: understanding the underlying data-structure that Git uses. Once you figure out how the DAG (directed acyclic graph) works in Git, everything falls in place. Join in to discover how to work yourself out of tricky situations and determine which workflow—commits versus stashes, branches versus tags, merge versus rebase—work best for you and your team.

What you'll learn-and how you can apply it

By the end of this live online course, you’ll understand:

  • How Git uses a DAG (directed acyclic graph) of commits to store “snapshots” of your working tree
  • How Git primitives like HEAD, branches, tags, commits, and stashes relate to this graph
  • The effects Git commands like commit, checkout, restore, switch, merge, rebase, and stash

And you’ll be able to:

  • Leverage Git to its fullest
  • Get out of tricky situations in Git
  • Design better workflows for you and your team

This training course is for you because...

  • You’re a developer who’s started your Git journey and wants to know how best to use this tool.
  • You’re a release or build engineer who wants to realize the full potential of Git.
  • You want to become the resident Git expert on your team and in your organization to help strategize how best to use Git.

Prerequisites

  • A working knowledge of Git for managing source code versioning

Recommended follow-up:

About your instructor

  • Raju Gandhi is a programmer, consultant, speaker, trainer, and all-around nice guy. He has worked in the software industry for over 15 years and has experience in both government and private sectors. Raju is a practitioner of both Agile and DevOps methods as well as good programming and architectural patterns and believes that finding the right balance between such practices will allow us to deliver software that our customers cherish. He is also a strong advocate of functional programming and a proponent of immutability across both software and hardware. Raju is a regular speaker at conferences around the country (and occasionally around the world) and has routinely participated in the No Fluff, Just Stuff tour. In his spare time, you will find Raju reading, playing with technology, or spending time with his wonderful (and significantly better) other half.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Git internals (30 minutes)

  • Presentation: A quick look at blobs, trees, and commits; no more deltas!
  • Hands-on exercises: Create a file with some content, “add” it to see the blob, then commit it to see the tree and the commit; create another file with the exact same content, add it to see that we only get one blob; commit it to see a new “tree” pointing to both files in the working directory
  • Q&A

Branches, tags, and HEAD (30 minutes)

  • Presentation: Branches; HEAD and “detached HEAD” mode; tags; annotated tags
  • Hands-on exercises: Create a branch and inspect .Git/refs/heads; inspect the contents of the files under .Git/refs/heads; look at .Git/HEAD; move around, switch branches, and see the effect of the same on .Git/HEAD; create a few (simple) tags, and inspect files under .Git/refs/tags; check out a commit (like HEAD~2) and inspect .Git/HEAD
  • Q&A

Break (5 minutes)

Reflog and stash (20 minutes)

  • Presentation: Reflog; stash; a better workflow
  • Hands-on exercise: Move around the repository and add to the Git history, each time, inspecting “Git reflog”; switch back to master, make a few commits, delete another branch, and then use reflog to recover that branch
  • Q&A

Merges and rebase (40 minutes)

  • Presentation: What’s the effect of a merge?; fast-forward merge; rebase; how it’s different than a merge; the power of the interactive rebase
  • Hands-on exercise: Perform a merge between a feature and master branch and see the effect on the DAG; use reflog to reset the feature branch to the commit prior to the commit; use rebase to perform the same operation as the merge and see the effect on the DAG
  • Q&A

Break (5 minutes)

Git workflows (40 minutes)

  • Presentation: Git commit and log hygiene; conventional commits and associated tooling; GitFlow—upsides and downsides; trunk-based development—upsides and downsides
  • Q&A

Wrap-up and Q&A (10 minutes)