Skip to content
ImagineWorld

Mastering Git

node_idnode-book_mastering-git
node_typenode-book
schema_profileworld.node_book.v1
statusactive
orthogonal_scopemanifold, entropy, authority, state
manifoldworld
entropymedium
authorityinforms
stateexternal
domainimagineworld.net
node_interiorrosetta_contract
unisonone evidence claim read five ways: seated in the ci-cd-gitops field, the work teaches mastering Git — the versioned flow of change through branches, merges, and history — its framework, regime, and stance agreeing on what it is
governed_byWORLD-MANIFOLD
constitutional_citationCONSTITUTION
peer_node_books
book_titleMastering Git
book_publisherPackt Publishing
total_chapters15
updated_at2026-10-14T05:38:37Z
local graph

node-book_mastering-git_chapter-01-git-basics-in-practice — Git Basics in Practice

node-book_mastering-git_chapter-02-developing-with-git — Developing with Git

node-book_mastering-git_chapter-03-managing-your-worktrees — Managing Your Worktrees

node-book_mastering-git_chapter-04-exploring-project-history — Exploring Project History

node-book_mastering-git_chapter-05-searching-through-the-repository — Searching Through the Repository

node-book_mastering-git_chapter-06-collaborative-development-with-git — Collaborative Development with Git

node-book_mastering-git_chapter-07-publishing-your-changes — Publishing Your Changes

node-book_mastering-git_chapter-08-advanced-branching-techniques — Advanced Branching Techniques

node-book_mastering-git_chapter-09-merging-changes-together — Merging Changes Together

node-book_mastering-git_chapter-10-keeping-history-clean — Keeping History Clean

node-book_mastering-git_chapter-11-managing-subprojects — Managing Subprojects

node-book_mastering-git_chapter-12-managing-large-repositories — Managing Large Repositories

node-book_mastering-git_chapter-13-customizing-and-extending-git — Customizing and Extending Git

node-book_mastering-git_chapter-14-git-administration — Git Administration

node-book_mastering-git_chapter-15-git-best-practices — Git Best Practices

Git is the most popular open source and distributed version-control system. Version-control systems help software teams manage changes to project sources over time. Using version control is a must in any collaborative development, and it’s useful even if you work alone.

Mastering Git will help novice Git professionals attain expert-level proficiency with Git, as well as understand Git concepts and the mental model behind basic and advanced Git tasks. Developers working with Git will be able to use its powerful capabilities to make their work easier. Mastering Git will help in various tasks during development, saving time and effort.

This book is meticulously designed to help you gain deeper insights into Git’s architecture and its underlying concepts, behavior, and best practices.

You’ll begin with a quick example of using Git for the collaborative development of a sample project, in order to establish a basic knowledge of Git’s operational tasks and concepts. As you progress through the book, subsequent chapters provide detailed descriptions of the various areas of Git use – from managing your own work, through source code archaeology, to working with other developers. You’ll learn how to examine and explore your project’s history, create and manage your contributions, set up repositories and branches for collaboration in centralized and distributed workflows, integrate work sent from other developers, customize and extend Git, and recover from repository errors.

Version control topics are accompanied by detailed descriptions of the relevant parts of Git’s architecture and behavior. By exploring advanced Git practices and getting to know the details of Git’s workings, you will attain a deeper understanding of its behavior, allowing you to customize and extend existing recipes and write your own.

If you are a Git user with a reasonable knowledge of it and you are familiar with its basic concepts, such as branching, merging, staging, and workflows, this is the book for you. If you have used Git for a long time, this book will help you understand how Git works, make full use of its power, and learn about advanced tools, techniques, and workflows.

If you are a system administrator, project lead, or operations manager, this book will help you to configure Git for better collaborative development, selecting a workflow and branching patterns that would fit best the needs of the team and a project.

A basic knowledge of installing Git and its software configuration management concepts is essential. The first chapter of the book, Git Basics in Practice, should work as a refresher and get you up to date. This book assumes that you have some skills in working from the command line, although this is not strictly necessary.

Chapter 1, Git Basics in Practice, serves as a reminder of the version-control basics with Git. The focus is on providing the practical aspects of the technology, using an example of the development of a simple project. This chapter will show and explain basic version-control operations for the development of an example project, as well as how two developers can use Git to collaborate.

Chapter 2, Developing with Git, shows how to selectively commit files and interactively select what to commit. You will learn how to create new revisions and new lines of development. This chapter introduces the concept of the staging area for commits (the index) and explains how to view and read differences between the working directory, the index, and the current revision. It will also teach you how to create, list, and switch branches, how to go back in history, and how to revert changes or amend the last commit.

Chapter 3, Managing Your Worktrees, teaches you how to manage your files in detail to prepare content for a new commit. It will explain the concept of the index and file status, teaching you how to examine the status of your working area, how to move file contents between a worktree, index, and repository, and how to change your file status. It will also show how to manage files that require special handling, introducing the concepts of ignored files and file attributes.

Chapter 4, Exploring Project History, introduces the concept of a graph of revisions and explains how this concept relates to the ideas of branches, tags, and the current branch in Git. You will learn how to select and view a revision or a range of revisions, as well as how to refer to them. These skills will help you focus on specific parts of project history, selecting the interesting part of it for further search.

Chapter 5, Searching Through the Repository, explores how to extract the information you want from selected commits. You will learn how to limit your search according to the revision metadata, such as the contents of the commit message, or look at the changes themselves. These skills will help you focus on specific parts of project history, extract information from it, examine what changed and when, and even find bugs by using history bisection.

Chapter 6, Collaborative Development with Git, presents a bird’s-eye view of the various ways to collaborate, showing different centralized and distributed workflows, their advantages and disadvantages, and how to set them up. This chapter will focus on repository-level interactions in collaborative development. You will also learn the concept of the chain of trust and how to use signed tags, signed merges, signed commits, and signed pushes.

Chapter 7, Publishing Your Changes, examines how Git exchanges information and data between your local repository and remote repositories, describes what the choices are with respect to transport protocols, and shows how Git can help manage credentials that might be needed to access those remote repositories. This chapter also teaches you how you can send your changes upstream so that they can appear in the repository with the official history of a project.

Chapter 8, Advanced Branching Techniques, dives deeper into the details of collaboration in distributed development. It explores the relationships between local branches and branches in remote repositories and describes techniques to synchronize branches and tags. You will learn the different patterns when using branches, including a trunk-based workflow and a topic branch (also called a feature branch) workflow, their advantages and disadvantages, and when to use them.

Chapter 9, Merging Changes Together, teaches you how to merge together changes from different parallel lines of development (that is, branches) using merge and rebase (and squash merge). This chapter will also explain the different types of merge conflicts, how to examine them, and how to resolve them. You will learn how to copy changes with cherry-pick and how to apply a single patch and a patch series.

Chapter 10, Keeping History Clean, explains why you might want to keep a clean history, when it can and should be done, and how it can be done. You will find step-by-step instructions on how to reorder, squash, and split commits. This chapter also demonstrates how you can recover from a history rewrite and explains what to do if you cannot rewrite history, how to revert the effect of commit, how to add a note to it, and how to change the view of a project’s history with a replacement mechanism.

Chapter 11, Managing Subprojects, explains and shows different ways to connect different projects in a single repository of a framework superproject, from a strong inclusion by embedding the code of one project in another (monorepos and subtrees) to a light connection between projects by nesting repositories (submodules and similar solutions).

Chapter 12, Managing Large Repositories, presents various solutions to the problem of large Git repositories, whether they are large because of a long history, contain a large number of files, or contain a project that includes some large files.

Chapter 13, Customizing and Extending Git, covers configuring and extending Git to fit your needs. You will find here details on how to set up the command line for easier use and a short introduction to graphical interfaces. This chapter explains how to automate Git with hooks (focusing on client-side hooks) – for example, how to make Git check whether a commit being created passes specific coding guidelines.

Chapter 14, Git Administration, focuses on the administrative side of Git. It briefly touches on the topic of serving Git repositories. Here, you will learn how to use server-side hooks for logging, access control, enforcing a development policy, and other purposes.

Chapter 15, Git Best Practices, presents a collection of version-control, generic and Git-specific recommendations and best practices. These cover issues such as managing the working directory, creating commits and a series of commits (pull requests), submitting changes for inclusion, and a peer review of changes.

To follow the examples used in this book and run the provided commands, you will need the Git software (https://git-scm.com/), preferably version 2.41.0 or later. Git is available for free on every platform (such as Linux, Windows, and macOS). All examples use the textual Git interface, using the bash shell (which is provided with Git for Microsoft Windows, where it is not present by default).

Software covered in the bookOperating system requirements
GitWindows, macOS, or Linux

To follow the development of a sample program, which is tracked in Chapter 1, Git Basics in Practice, as a demonstration of using version control, you would also need a web browser and a text editor (although a programmers’ editor or IDE is preferred).

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “Then, Bob writes JavaScript source code (random.js) that is responsible for web application behavior.”

A block of code is set as follows:

function getRandomInt(max) {
return Math.floor(Math.random() * max) + 1;
}
function generateRandom() {
let max = document.getElementById('max').value;
alert(getRandomInt(max));
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<body>
<button disabled>Generate number</button>
<label for="max">up to</label>
<input type="number" id="max" name="rand_max" value="10" />
<div id="result"></div>
</body>
</html>

Any command-line input or output is written as follows:

$ mkdir css
$ cd css

Bold: Indicates a new term, an important word, or words that you see on screen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Select System info from the Administration panel.”

Tips or important notes

Appear like this.