Praise for Head First Git
Head First Git is a gem. The book is a clear, fun, and engaging introduction to a very powerful and complex tool. The pace, scope, and structure make it approachable while providing readers a solid foundation from which to continue their journey learning Git.
Matt Cordial, staff software engineer, Experian Decision Analytics
Software developers depend on their tools to get the job done, but that often means we work with just enough knowledge to be dangerous. And while the basics of Git can be understood in a few hours, the nuance, the power, the depth can take years to master. Seemingly every page of Head First Git contains a nugget or explanation of something you only thought you understood. Regardless of your experience level with Git, Raju will make you better at using this invaluable tool.
Nate Schutta, architect and developer advocate at VMware and author of Thinking Architecturally and Responsible Microservices
Version control is hard. Explaining version control is harder. Head First Git reforms dry, difficult, highly technical information into an enjoyable and playful story that not only makes learning fun but also very effective. Author Raju Gandhi is sure to delight your neurons with amazing analogies, characters, and adventures in glamping. If you are a first-time Git user, this book will be one youll want to git checkout.
Daniel Hinojosa, self-employed programmer, speaker, and instructor at EvolutionNext.com
I wish this book existed a decade ago when I first started using Git extensively. The books conversational style, along with real-world analogies for common Git concepts, will make this a fun read. Regardless of your level of experience, youll enjoy reading this book and will learn something new about Git.
Nihar Shah, software consultant
Head First Git
by Raju Gandhi
Copyright 2022 DefMacro Software, LLC. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly Media books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (.
Series Creators: Kathy Sierra, Bert Bates
Acquisitions Editor: Melissa Duffield
Development Editor: Sarah Grey
Cover Designer: Karen Montgomery
Brain Image on Spine: Eric Freeman
Production Editor: Kristen Brown
Proofreader: nSight, Inc.
Indexer: nSight, Inc.
Page Viewers: Buddy and Skye (dogs) and Zara (the cat)
Printing History:
January 2022: First Edition.
The OReilly logo is a registered trademark of OReilly Media, Inc. The Head First series designations, Head First Git, and related trade dress are trademarks of OReilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and OReilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and the author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
No dogs or chefs were harmed in the making of this book.
ISBN: 978-1-492-09251-3
[LSI]
[2022-01-13]
Author of Head First Git
Raju Gandhi is the founder of DefMacro Software, LLC. He lives in Columbus, Ohio, along with his wonderful wife, Michelle; their sons, Mason and Micah; and their three furry family memberstheir two dogs, Buddy and Skye, and Princess Zara, their cat.
Raju is a consultant, author, teacher, and regularly invited speaker at conferences around the world. In his career as both a software developer and a teacher, he believes in keeping things simple. His approach is always to understand and explain the why, as opposed to the how.
Raju blogs at https://www.looselytyped.com, and can be found on Twitter as @looselytyped. Hes always looking to make new friends. You can find his contact information at https://www.rajugandhi.com.
Table of Contents (the real thing)
Your brain on Git. Here you are trying to learn something, while your brain is doing you a favor by making sure the learning doesnt stick. Your brains thinking, Better leave room for more important things, like which wild animals to avoid and whether naked snowboarding is a bad idea. So how do you trick your brain into thinking that your life depends on knowing Git?
You need version control. Every software project begins with an idea, implemented in source code. These files are the magic that powers our applications, so we must treat them with care. We want to be sure that we keep them safe, retain a history of changes, and attribute credit (or blame!) to the rightful authors. We also want to allow for seamless collaboration between multiple team members.
And we want all this in a tool that stays out of our way, springing into action only at the moment of our choosing.
Does such a magical tool even exist? If youre reading this, you might have guessed the answer. Its name is Git! Developers and organizations around the world love Git. So what is it that makes Git so popular?
You can walk and chew gum at the same time. Git old-timers will tell you, as they recline in their lawn chairs (sipping their handcrafted green tea), that one of Gits biggest selling points is the ease with which you can create branches. Perhaps you have been assigned a new feature, and while you are working on it, your manager asks you to fix a bug in production. Or maybe you just got around to putting the finishing touches on your latest change, but inspiration has struck and youve just thought of a better way of implementing it. Branches allow you to work on multiple, completely disconnected pieces of work on the same codebase at the same time, independently of one another. Lets see how!
You ready to do some digging, Sherlock? As you continue to work in Git, youll create branches, make commits, and merge your work back into the integration branches. Each commit represents a step forward, and the commit history represents how you got there. Every so often, you might want to look back to see how you got to where you are, or perhaps if two branches have diverged from one another. Well start this chapter by showing you how Git can help you visualize your commit history.