Free Sample
+ Collection

Git Version Control Cookbook

Cookbook
Aske Olsson, Rasmus Voss

90 hands-on recipes that will increase your productivity when using Git as a version control system
$26.99
$44.99
RRP $26.99
RRP $44.99
eBook
Print + eBook

Want this title & more?

$16.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781782168454
Paperback340 pages

About This Book

  • Filled with practical recipes that will teach you how to use the most advanced features of the Git system
  • Improve your productivity by learning to work faster, more efficiently, and with more confidence
  • Discover tips and tricks that will show you when and how to use the advanced features of Git

Who This Book Is For

If you are a software developer or a build and release engineer who uses Git in your daily work and want to take your Git knowledge to the next level, then this book is for you. To understand and follow the recipes included in this book, basic knowledge of Git command-line code is mandatory.

Table of Contents

Chapter 1: Navigating Git
Introduction
Git's objects
The three stages
Viewing the DAG
Extracting fixed issues
Getting a list of the changed files
Viewing history with Gitk
Finding commits in history
Searching through history code
Chapter 2: Configuration
Configuration targets
Querying the existing configuration
Templates
A .git directory template
A few configuration examples
Git aliases
The refspec exemplified
Chapter 3: Branching, Merging, and Options
Introduction
Managing your local branches
Branches with remotes
Forcing a merge commit
Using git rerere to merge known conflicts
The difference between branches
Chapter 4: Rebase Regularly and Interactively, and Other Use Cases
Introduction
Rebasing commits to another branch
Continuing a rebase with merge conflicts
Rebasing selective commits interactively
Squashing commits using an interactive rebase
Changing the author of commits using a rebase
Auto-squashing commits
Chapter 5: Storing Additional Information in Your Repository
Introduction
Adding your first Git note
Separating notes by category
Retrieving notes from the remote repository
Pushing notes to a remote repository
Tagging commits in the repository
Chapter 6: Extracting Data from the Repository
Introduction
Extracting the top contributor
Finding bottlenecks in the source tree
Grepping the commit messages
The contents of the releases
Chapter 7: Enhancing Your Daily Work with Git Hooks, Aliases, and Scripts
Introduction
Using a branch description in the commit message
Creating a dynamic commit message template
Using external information in the commit message
Preventing the push of specific commits
Configuring and using Git aliases
Configuring and using Git scripts
Setting up and using a commit template
Chapter 8: Recovering from Mistakes
Introduction
Undo – remove a commit completely
Undo – remove a commit and retain the changes to files
Undo – remove a commit and retain the changes in the staging area
Undo – working with a dirty area
Redo – recreate the latest commit with new changes
Revert – undo the changes introduced by a commit
Reverting a merge
Viewing past Git actions with git reflog
Finding lost changes with git fsck
Chapter 9: Repository Maintenance
Introduction
Pruning remote branches
Running garbage collection manually
Turning off automatic garbage collection
Splitting a repository
Rewriting history – changing a single file
Back up your repositories as mirror repositories
A quick submodule how-to
Subtree merging
Submodule versus subtree merging
Chapter 10: Patching and Offline Sharing
Introduction
Creating patches
Creating patches from branches
Applying patches
Sending patches
Creating Git bundles
Using a Git bundle
Creating archives from a tree
Chapter 11: Git Plumbing and Attributes
Introduction
Displaying the repository information
Displaying the tree information
Displaying the file information
Writing a blob object to the database
Writing a tree object to the database
Writing a commit object to the database
Keyword expansion with attribute filters
Metadata diff of binary files
Storing binaries elsewhere
Checking the attributes of a file
Attributes to export an archive
Chapter 12: Tips and Tricks
Introduction
Using git stash
Saving and applying stashes
Debugging with git bisect
Using the blame command
Color UI in the prompt
Autocompletion
Bash prompt with status information
More aliases
Interactive add
Interactive add with Git GUI
Ignoring files
Showing and cleaning ignored files

What You Will Learn

  • Understand the Git data model and how you can navigate the database with simple commands
  • Learn how you can recover lost commits/files
  • Discover how you can force rebase on some branches and use regular Git merge on other branches
  • Extract metadata from a Git repository
  • Familiarize yourself with Git notes
  • Discover how you can work offline with Git
  • Debug with Git and use various techniques to find the faulty commit

In Detail

Starting with the Git data model, you will learn how Git stores files and how it looks at commits. You will then learn how you can recover from mistakes; from committing on the wrong branch to recovering lost commits/files. Next, you will discover how you can force rebase on some branches and use regular Git merge on other branches. You will also learn how to extract information from the repository.

As you progress through this book, you will learn how you can automate the usual Git processes by utilizing the hook system built into Git. The book also covers advanced repository management, including different options to rewrite the history of a Git repository. Finally, you will discover how you can work offline with Git, how to track what is going on behind the scenes, and how to use the stash for different purposes.

Authors

Read More