𝔖 Scriptorium
✦   LIBER   ✦

πŸ“

Mastering Git: Attain expert-level proficiency with Git by mastering distributed version control features

✍ Scribed by Jakub NarΔ™bski


Publisher
Packt
Year
2024
Tongue
English
Leaves
616
Edition
2
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Harness the full power of the Git version control system, gaining insights into Git best practices and strengthening your understanding of its architecture, underlying concepts, and behavior

Key Features
- Set up Git for solo and collaborative development as well as for code, documentation, configuration, or data
- Leverage the Git version control system to customize and extend existing recipes, and write your own
- Discover how to efficiently manage large and complex repositories

Book Description
Developers often feel overwhelmed by complex version control issues, especially when managing large repositories. This updated second edition of our Git guide empowers you to tackle these challenges head-on and emerge as a Git pro.

The book gets you up to speed with the latest Git version, its features, and advanced branching techniques, helping you master complex development scenarios. A new chapter on tackling challenges while managing large repositories has been added, providing invaluable strategies for efficient version control with Git. The book goes beyond the basics to take you through Git's architecture, behavior, and best practices in depth. The chapters help you develop a clear understanding of customizing workflows, creating unique solutions, and tackling any version control hurdle. As you advance, you'll explore a wide range of functionalities, from examining project history to collaborating seamlessly with teammates. Detailed descriptions guide you through managing your work, collaborating with others, administering Git, and navigating project history.

By the end of this book, you'll have become a Git pro and be confident enough to handle advanced branching, manage large repositories, customize workflows, collaborate effectively, and troubleshoot any version control issues.

What You Will Learn
- Explore project history and find revisions using different criteria
- Manage your working directory and staging area
- Set up repositories and branches for collaboration
- Configure and set up support for the chosen workflow
- Submit your own contributions and integrate contributions made by others
- Customize Git behavior system-wide, from per-user to per-file basis
- Perform Git administration to set up and manage repositories

Who this book is for
This book is for developers looking to elevate their Git skills beyond the basics. Whether you're a seasoned developer or just getting started with version control, this book will help you leverage Git for efficient collaboration, code management, and improved workflows. The book also equips DevOps professionals with the knowledge they need to configure Git for seamless integration within DevOps workflows, enabling smoother collaboration between development and operations teams.

✦ Table of Contents


Mastering Git
Contributors
About the author
About the reviewer
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Share Your Thoughts
Download a free PDF copy of this book
Part 1 - Exploring Project History and Managing Your Own Work
1
Git Basics in Practice
Technical requirements
A brief introduction to version control and Git
Git by example
Setup and initialization
Collaborative development
Branching and merging
Summary
Questions
Answers
Further reading
2
Developing with Git
Creating a new commit
How a new commit extends a project’s history
The index β€” a staging area for commits
Examining the changes to be committed
Selective commit
Amending a commit
Working with branches and tags
Creating a new branch
Creating orphan branches
Selecting and switching to a branch
Listing branches and tags
Rewinding or resetting a branch
Deleting a branch
Changing the branch name
Summary
Questions
Answers
Further reading
3
Managing Your Worktrees
Ignoring files
Marking files as intentionally untracked (ignored)
Which types of files should be ignored?
Listing ignored files
Trick – ignoring changes in tracked files
File attributes
Identifying binary files and end-of-line conversions
Diff and merge configuration
Transforming files (content filtering)
Keyword expansion and substitution
Other built-in attributes
Defining attribute macros
Fixing mistakes with the reset command
Rewinding the branch head, softly
Resetting the branch head and the index
Discarding changes and rewinding the branch
Safer reset – keeping your changes
Stashing away your changes
Using git stash
Stash and the staging area
Stash internals
Managing worktrees and the staging area
Examining files and directories
Searching file contents
Un-tracking, un-staging, and un-modifying files
Resetting a file to the old version
Cleaning the working area
Multiple working directories
Summary
Questions
Answers
Further reading
4
Exploring Project History
DAGs
Whole-tree commits
Branches and tags
Branch points
Merge commits
Single revision selection
HEAD – the implicit revision
Branch and tag references
The --branches, --tags, and similar options
SHA-1 and the shortened SHA-1 identifier
Ancestry references
Reverse ancestry references – git-describe output
Reflogging shortnames
Upstreaming remote-tracking branches
Selecting revisions via a commit message
Selecting the revision range
Single revision as a revision range
Double-dot notation
Creating the range by including and excluding revisions
The revision range for a single revision
Triple-dot notation
Summary
Questions
Answers
Further reading
5
Searching Through the Repository
Searching the history
Limiting the number of revisions
Matching revision metadata
Searching changes in revisions
Selecting types of changes
History of a file
Path limiting
History simplification
Blame β€” the line-wise history of a file
Finding bugs with git bisect
Starting the git bisect process
Finding the buggy commit
Automating testing during the git bisect process
Selecting and formatting the git log output
Predefined and user-defined output formats
Including, formatting, and summing up changes
Summarizing contributions
Mapping authors
Viewing a revision and a file at revision
Summary
Questions
Answers
Further reading
Part 2 - Working with Other Developers
6
Collaborative Development with Git
Collaborative workflows
Bare repositories
Interacting with other repositories
The centralized workflow
The peer-to-peer or forking workflow
The maintainer or integration manager workflow
The hierarchical or dictator-and-lieutenants workflow
Managing remote repositories
The β€œorigin” remote
Listing and examining remotes
Adding a new remote
Updating information about remotes
Support for triangular workflows
Chain of trust
Content-addressed storage
Lightweight, annotated, and signed tags
Signed commits
Merging signed tags (merge tags)
Summary
Questions
Answers
Further reading
7
Publishing Your Changes
Transport protocols and remote helpers
Local transport
Smart transports
Legacy (dumb) transports
Offline transport with bundles
Remote transport helpers
Credentials/password management
Publishing your changes upstream
Pushing to a public repository
Generating a pull request
Exchanging patches
Summary
Questions
Answers
Further reading
8
Advanced Branching Techniques
The purpose of branching
Isolation versus integration
The path to production release
Long-running and short-lived branches
Visibility of branches
Alternatives to branching
Visibility without integration
Branching patterns
Integration patterns
Release engineering
Other branching patterns involving long-lived branches
Other types of short-lived branches
Branching workflows and release engineering
The release and trunk branches workflow
The graduation branches workflow
The topic branches workflow
git-flow – a successful Git branching model
Ship/Show/Ask – a modern branching strategy
Fixing a security issue
Interacting with branches in remote repositories
Upstream and downstream
Remote-tracking branches and refspec
Fetching and pulling versus pushing
Fetching and pushing branches and tags
Push modes and their use
Summary
Questions
Answers
Further reading
9
Merging Changes Together
Methods of combining changes
Merging branches
Copying and applying a changeset
Rebasing a branch
Squash merge
Resolving merge conflicts
The three-way merge
Examining failed merges
Avoiding merge conflicts
Dealing with merge conflicts
Summary
Questions
Answers
Further reading
10
Keeping History Clean
An introduction to Git internals
Git objects
Plumbing and porcelain Git commands
Rewriting history
Amending the last commit
The interactive rebase
External tools – patching management interfaces
Rewriting project history with Git filter-repo
External tools for large-scale history rewriting
The perils of rewriting published history
Amending history without rewriting
Reverting a commit
Storing additional information with notes
Using git replace
Summary
Questions
Answers
Further reading
Part 3 - Managing, Configuring, and Extending Git
11
Managing Subprojects
Building a living framework
Managing dependencies outside of Git
Manually importing the code into your project
A Git subtree solution for embedding the subproject code
Creating a remote for a subproject
Adding a subproject as a subtree
Cloning and updating superprojects with subtrees
Getting updates from subprojects with a subtree merge
Showing changes between a subtree and its upstream
Sending changes to the upstream of a subtree
The Git submodules solution – a repository inside a repository
Gitlinks, .git files, and the git submodule command
Adding a subproject as a submodule
Cloning superprojects with submodules
Updating submodules after superproject changes
Examining changes in a submodule
Getting updates from the upstream of the submodule
Sending submodule changes upstream
Transforming a subfolder into a subtree or submodule
Subtrees versus submodules
Use cases for subtrees
Use cases for monorepo
Use cases for submodules
Third-party subproject management solutions
Summary
Questions
Answers
Further reading
12
Managing Large Repositories
Scalar – Git at scale for everyone
Handling repositories with a very long history
Using shallow clones to get truncated history
Cloning only a single branch
Making operations faster in repositories with a long history
Handling repositories with large binary files
Splitting the binary asset folder into a separate submodule
Storing large binary files outside the repository
Handling repositories with a large number of files
Limiting the number of working directory files with sparse checkout
Reducing the local repository size with sparse clone
Faster checking for file changes with filesystem monitor
Summary
Questions
Answers
Further reading
13
Customizing and Extending Git
Git on the command line
Git-aware command prompt
Command-line completion for Git
Autocorrection for Git commands
Making the command line prettier
Alternative command line
Graphical interfaces
Types of graphical tools
Graphical diff and merge tools
Graphical interface examples
Configuring Git
Command-line options and environment variables
Git configuration files
Per-file configuration with gitattributes
Automating Git with hooks
Installing a Git hook
A template for repositories
Client-side hooks
Server-side hooks
Extending Git
Command aliases for Git
Adding new Git commands
Credential helpers and remote helpers
Summary
Questions
Answers
Further reading
14
Git Administration
Repository maintenance
Automatic housekeeping with git-gc
Periodic maintenance with git-maintenance
Data recovery and troubleshooting
Recovering a lost commit
Troubleshooting Git
Git on the server
Server-side hooks
Using hooks to implement Git-enforced policy
Signed pushes
Serving Git repositories
Tools to manage Git repositories
Tips and tricks to host repositories
Augmenting development workflows
Defining development workflows in the repository
GitOps – using Git for operational procedures
Summary
Questions
Answers
Further reading
15
Git Best Practices
Starting a project
Dividing work into repositories
Selecting the collaboration workflow
Choosing which files to keep under version control
Working on a project
Working on a topic branch
Deciding what to base your work on
Splitting changes into logically separate steps
Writing a good commit message
Preparing changes for submission
Integrating changes
Submitting and describing changes
The art of the change review
Responding to reviews and comments
Other recommendations
Don’t panic, recovery is almost always possible
Don’t change the published history
Numbering and tagging releases
Automate where possible
Summary
Further reading
Index
Why subscribe?
Other Books You May Enjoy
Packt is searching for authors like you
Share Your Thoughts
Download a free PDF copy of this book


πŸ“œ SIMILAR VOLUMES


Mastering Git: Attain expert-level profi
✍ Jakub Narebski πŸ“‚ Library πŸ“… 2016 πŸ› Packt Publishing 🌐 English

Git is one of the most popular types of Source Code Management (SCM) and Distributed Version Control System (DVCS). Despite the powerful and versatile nature of the tool enveloping strong support for nonlinear development and the ability to handle large projects efficiently, it is a complex tool and

Git Prodigy : Mastering Version Control
✍ Ebenezer Don πŸ“‚ Library πŸ“… 2023 🌐 English

If you want to master Git, GitHub, and the enriching world of open-source contributions, even without any prior knowledge, this guide is your best bet. Git Prodigy is your clear, concise guide to mastering Git and GitHub. This book focuses on practical insights, avoiding unnecessary technical jar

Distributed Version Control with Git: Ma
✍ Lars Vogel, Alex Blewitt πŸ“‚ Library πŸ“… 2014 πŸ› Lars Vogel 🌐 English

This book gives a practical introduction into the Git version control system. It explains the setup and the usage of Git repositories using the Git command line tools. <br /> <br />At the beginning you learn how to configure and setup new Git repositories, how to add and commit changes using a loc

Version control with Git powerful techni
✍ Loeliger, Jon πŸ“‚ Library πŸ“… 2009 πŸ› O'Reilly Media 🌐 English

<p><em>Version Control with Git</em> takes you step-by-step through ways to track, merge, and manage software projects, using this highly flexible open-source version control system. Git permits practically an infinite variety of methods for development and collaboration, but its flexibility also me

Version control with Git powerful techni
✍ Loeliger, Jon πŸ“‚ Library πŸ“… 2009 πŸ› O'Reilly Media 🌐 English

<p><em>Version Control with Git</em> takes you step-by-step through ways to track, merge, and manage software projects, using this highly flexible open-source version control system. Git permits practically an infinite variety of methods for development and collaboration, but its flexibility also me

Version Control With Git
✍ Jon Loeliger πŸ“‚ Library πŸ“… 2009 πŸ› O'Reilly Media 🌐 English

Version Control with Git takes you step-by-step through ways to track, merge, and manage software projects, using this highly flexible, open source version control system. Git permits virtually an infinite variety of methods for development and collaboration. Created by Linus Torvalds to manage deve