Advanced
Git
By Jawwad Ahmed & Chris Belanger
Advanced Git
Jawwad Ahmad & Chris Belanger
Copyright 2021 Razeware LLC.
Notice of Rights
All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed by any means without prior written permission of the copyright owner.
Notice of Liability
This book and all corresponding materials (such as source code) are provided on an as is basis, without warranty of any kind, express of implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of other dealing in the software.
Trademarks
All trademarks and registered trademarks appearing in this book are the property of their own respective owners.
Book License
By purchasing Advanced Git, you have the following license:
You are allowed to use and/or modify the source code in Advanced Git in as many apps as you want, with no attribution required.
You are allowed to use and/or modify all art, images and designs that are included in Advanced Git in as many apps as you want, but must include this attribution line somewhere inside your app: Artwork/images/designs: from Advanced Git, available at www.raywenderlich.com.
The source code included in Advanced Git is for your personal use only. You are NOT allowed to distribute or sell the source code in Advanced Git without prior authorization.
This book is for your personal use only. You are NOT allowed to sell this book without prior authorization, or distribute it to friends, coworkers or students; they would need to purchase their own copies.
All materials provided with this book are provided on an as is basis, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
All trademarks and registered trademarks appearing in this guide are the properties of their respective owners.
Before You Begin
This section tells you a few things you need to know before you get started, such as what youll need for hardware and software, where to find the project files for this book, and more.
What You Need
To follow along with this book, youll need the following:
Git 2.32 or later. Git is the software package youll use for all the work in this book. There are installers for macOS, Windows and Linux available for free from the official Git page here: https://git-scm.com/downloads. Weve tested this book on Git 2.32.0, but you can follow along with older versions of Git as well.
Book Source Code & Forums
Book source code
The materials for this book are all available in the GitHub repository here:
You can download the entire set of materials for the book from that page.
Forum
Weve also set up an official forum for the book at https://forums.raywenderlich.com/c/books/advanced-git. This is a great place to ask questions about the book or to submit any errors you may find.
Dedications
For Russ and Skip.
Chris Belanger
To Linus Torvalds, for freeing us from SVN.
Jawwad Ahmad
About the Author
Chris Belanger is an author of this book. He is the CMO of raywenderlich.com. In the programming world, Chris has over 25 years of experience with multiple database platforms, real-time industrial control systems, and enterprise healthcare information systems. When he kicks back, you can usually find Chris with guitar in hand, looking for the nearest beach, or exploring the lakes and rivers in his part of the world in a canoe.
Jawwad Ahmad is an author of this book. He is an iOS Developer that spends way too much time using the power of Git to attempt to craft the most ideal commits. He currently works as a Software Engineer at a technology company in the San Francisco Bay Area.
About the Editors
Aaron Douglas is the final pass editor for this book. He was that kid taking apart the mechanical and electrical appliances at five years of age to see how they worked. He never grew out of that core interest - to know how things work. He took an early interest in computer programming, figuring out how to get past security to be able to play games on his dads computer. Hes still that feisty nerd, but at least now he gets paid to do it. Aaron works for Automattic (WordPress.com, WooCommerce, Tumblr, SimpleNote) as a Mobile Lead primarily on the WooCommerce mobile apps. Find Aaron on Twitter as @astralbodies or at his blog at https://aaron.blog.
Introduction
There are usually two reasons a person picks up a book about Git: one, they are unusually curious about how the software works at a deeper level; or two, theyre frustrated and need something to solve their problems now.
Whatever situation brought you here, welcome! Im happy to have you onboard. I came to write this book for both of the above reasons. I am a tinkerer and hacker by nature, and I love going deep into the internals of software to see what makes them tick. But I, like you, found Git at first to be an inscrutable piece of software. My brain, which had been trained in software development through the late 1990s, found version control packages like SVN soothing, with their familiar client-server architecture, Windows shell integration, and rather straightforward, albeit heavy, processes.
When I came to use Git and GitHub about seven years ago, I found it inscrutable at best; it seemed no matter which way I turned, Git was telling me I had a merge conflict, or it was merging changes from the master branch into my current branch, or quite often complaining about unstaged changes. And why was it called a pull request, when clearly I was trying to push my changes into the master branch?
Little by little, I learned more about how Git worked; how to solve some of the common issues I encountered, and I eventually got to a point where I felt comfortable using it on a daily basis.
Enter the video courses
In early 2017, my colleague Sam Davies created a conference talk, titled Mastering Git, and from that, two video courses at raywenderlich.com: Beginning Git and Mastering Git. Those two courses form the basis of this book, but it always nagged me a little that, while Sams video version of the material was quite pragmatic and tied nicely into using both the command line and graphical tools to solve common Git workflow problems, I always felt like there was a bit of detail missing; the kind of information that would lead a curious mind to say I see the
Next page