O'Reilly logo
live online training icon Live Online training

Git Troubleshooting

How to solve practically any problem that comes your way

Topic: Software Development
Brent Laster

If you’ve been using Git for any length of time, you probably have a certain level of comfort with it. You know the commands to use to get your work done and the standard options to make that work easier. But what happens when something goes wrong, or you need to do something other than the workflow you’re used to? Or worse, what if you need to dig into the actual repository to solve a problem?

Join expert Brent Laster to gain the tools, knowledge, and hands-on experience you need to deal with many of the uncommon issues you’re likely to run into with Git, from trying to recover from or undo an operation to making strategic changes across a series of commits to learning how to save space and manage the scope and size of your repositories. Armed with this information, you’ll be in a position to deal with practically any challenge with your repositories that comes your way.

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

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

  • How to recover from almost any mistake in a repository
  • How to search for and quickly find content across commits
  • How to map files to internal Git objects and access and work with low-level objects
  • How to use rebase and related functions to precisely merge and add commits from other branches
  • How to get information on the low-level attributes of your repositories (such as storage) and manage them (such as freeing up storage)

And you’ll be able to:

  • Roll back or undo most operations
  • Quickly locate the commit that first introduced a problem or change
  • Easily find key content in your repository
  • Look at and understand objects in the repository
  • Identify which objects in the repository map to which files in your dev area
  • Use rebase and related functionality to update and merge selected commits
  • Make your repositories as efficient and small as possible

This training course is for you because...

  • You’re a Git user who wants to better understand how to recover from problems.
  • You’re an admin for a Git repository who needs to be able to help others with issues or problems.
  • You want to become more familiar with Git’s advanced features and lower-level commands.

Prerequisites

  • A computer with Git installed
  • A working knowledge of Git’s basic commands and workflow

Recommended preparation:

Recommended follow-up:

About your instructor

  • Brent Laster is a global trainer, author, and speaker on open source technologies as well as an R&D director at a top technology company. He’s been involved in the software industry for more than 25 years, holding various technical and management positions. Brent has always tried to make time to learn and develop both technical and leadership skills and share them with others. He believes that regardless of the topic or technology, there’s no substitute for the excitement and sense of potential that come from providing others with the knowledge they need to accomplish their goals.

Schedule

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

How to quickly find things in Git (35 minutes)

  • Presentation: Using git grep and options to search for content across commits; using git log in various forms to get targeted change information over time; identifying who made changes to particular lines in files with git blame; using git bisect to quickly identify where a error or change was introduced in a long chain of commits and automating the process
  • Hands-on exercise: Use git bisect to find where an error was introduced in a set of commits
  • Q&A

Recovering from mistakes (30 minutes)

  • Presentation: Recovering, undoing, and rolling back changes, including targeting specific changes for individual files and settings in commits
  • Hands-on exercise: Use filter-branch to remove a file from all commits and update the author and email address associated with a set of commits in the history
  • Q&A
  • Break (5 minutes)

Slicing and dicing: Rearranging content (35 minutes)

  • Presentation: Using git cherry-pick to surgically migrate one commit from any point in a branch to another branch; using advanced rebasing to select a range of commits from one branch to merge into another; making a subdirectory of a project into the project’s root with filter-branch and the subdirectory filter; splitting out a subset of content from a repository into another repository using the subtree command; leveraging interactive rebasing to rewrite commit history including squashing, deleting, and updating commits at any point in the history
  • Hands-on exercise: Use cherry-picking and interactive rebasing to squash and update commits in the history
  • Q&A

Mapping Git internal storage: How to work with low-level objects in your repository (30 minutes)

  • Presentation: Using Git plumbing (lower-level) commands to map and work with the internal representations that Git uses to manage objects in its repositories
  • Hands-on exercise: Map user content to internal repository objects
  • Q&A
  • Break (5 minutes)

Maintenance and cleanup: Garbage collection, verification, and cleanup for your repositories (35 minutes)

  • Presentation: Using git gc to do garbage collection; leveraging git prune to remove dangling objects; running git fsck to verify the integrity and validity of objects in a repository; checking disk space consumption with git count-objects
  • Hands-on exercise: Validate and clean up a Git repository
  • Q&A

Wrap-up and Q&A (5 minutes)