Version Control with Git
by Prem Kumar Ponuthorai and Jon Loeliger
Copyright 2021 Prem Kumar Ponuthorai. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Acquisitions Editor: Melissa Duffield
- Development Editor: Virginia Wilson
- Production Editor: Beth Kelly
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Kate Dullea
- October 2022: Third Edition
Revision History for the Early Release
- 2021-06-22: First Release
- 2021-10-26: Second Release
See http://oreilly.com/catalog/errata.csp?isbn=9781492091196 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Version Control with Git, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
The views expressed in this work are those of the authors, and do not represent the publishers views. While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-492-09112-7
[FILL IN]
Preface
A Note for Early Release Readers
With Early Release ebooks, you get books in their earliest formthe authors raw and unedited content as they writeso you can take advantage of these technologies long before the official release of these titles.
This will be the preface of the final book.
If you have comments about how we might improve the content and/or examples in this book, or if you notice missing material within this chapter, please reach out to the editor at .
Git is a free, open source, distributed version control system created by Linus Torvalds. Git requires low operational overhead, yet is flexible and powerful enough to support the demands of complex, and large scale, distributed software development projects.
Our goal in this book is to show you how to get the most out of Git and how to manage a git repository with ease. By the end, you will have learned Gits philosophy, fundamental concepts, and intermediate to advanced skills for tracking content, collaborating and managing your projects across teams.
Who This book is For
We wrote this book with software engineers (developers, infrastructure engineers, DevOps, etc.) in mind as our primary audience. As such, most of the concepts and examples we use relate to the daily routine and tasks of folks in the software development industry. However, Git is robust enough to track content in areas as varied as data science, graphic design and book authoring, just to name a few. (Case in point: We used git as our underlying versioning system to keep track of reviews and edits while writing this book!). Regardless of your title or level of proficiency, if you are using git as your version control system, you will find value in these pages.
Essential know hows
Prior experience with any version control system, their aims and goals will be a helpful foundation to understand how Git works and to build upon as you read this book. You should have some familiarity using any command-line tool, such as the Unix Shell, along with basic knowledge of shell commands, because we use a lot of command-line instructions in the examples and discussions in the book. General understanding of programming concepts is also a plus.
We developed the examples on Mac OS X and Ubuntu Linux environments. The examples should work under other platforms such as Debian, Solaris or Windows Operating System (using git installed command-line tools, eg. Git for Windows), but you can expect slight variations.
When following examples, some exercises may require system level operations which need root access on machines. Naturally, in such situations, you should have a clear understanding of the responsibilities of operations that need root access.
New in this revision
In this third edition, we take an entirely new, modular approach to the topics by breaking down the concepts of Git. We start by introducing you to the basics and fundamental philosophy of Git, then gradually build upon intermediate commands to help you efficiently supplement your daily development workflow, and finally conclude with advanced git commands and concepts to help you become proficient in understanding the inner mechanics of how Git works under the hood.
Another change we made in this edition was adding more visual illustrations to explain complex git concepts to give you a mental model for easier comprehension. We also highlight features from the latest release of Git, and provide you with examples and tips which can help improve your current distributed development workflow.
Navigating the Book
We organized this edition into categories according to the readers familiarity and experience using Git. While we categorize the sections to get progressively more advanced to incrementally build your proficiency with git, we designed the chapters within each section so that you can leverage the content either as standalone topics or as a series of topics building on each other sequentially.
We strove to apply a consistent structure and a consistent approach to teaching concepts in every chapter. We encourage you to take a moment to internalize this format. This will help you leverage and navigate the book as a handy reference at any point in time in the future.
If you have picked up the book amidst juggling other responsibilities and are wondering what would be the best order to hit the ground running, fret not. The matrix below will help guide you towards the chapters we feel will help you gain the most in the least amount of time.
Table P-1. Categories Matrix
| Introduction to Git | Thinking in Git | Fundamentals of Git | Intermediate Git Commands | Advanced Git Concepts | Tips and Tricks | Git in the Mainstream |
---|
Software Engineering | x | x | x | x | x | x | x |
Data Scientist | x | x | x | x |
Graphic Designers | x | x | x | x |
Academia | x | x | x | x |
Content Authors | x | x | x | x |
Note
The categories matrix is provided as a rough guideline