Pragmatic Guide To Git Travis Swicegood pdf download
Pragmatic Guide To Git Travis Swicegood pdf download
https://ebookbell.com/product/pragmatic-guide-to-git-travis-
swicegood-2544508
https://ebookbell.com/product/pragmatic-guide-to-javascript-
christophe-porteneuve-2318292
https://ebookbell.com/product/pragmatic-guide-to-sass-hampton-catlin-
michael-lintorn-catlin-2506830
https://ebookbell.com/product/pragmatic-guide-to-subversion-1st-
edition-mike-mason-36180144
https://ebookbell.com/product/pragmatic-guide-to-sass-3-hampton-
catlin-michael-lintorn-catlin-6856020
Pragmatic Guide To Subversion 1st Edition Mike Mason
https://ebookbell.com/product/pragmatic-guide-to-subversion-1st-
edition-mike-mason-27411418
https://ebookbell.com/product/a-pragmatic-guide-to-real-options-tom-
arnold-5220382
https://ebookbell.com/product/a-pragmatic-guide-to-business-process-
modelling-new-2nd-ed-holt-5308402
https://ebookbell.com/product/a-pragmatic-guide-to-real-options-tom-
arnold-auth-5379582
https://ebookbell.com/product/a-pragmatic-guide-to-competency-tools-
frameworks-and-assessment-jon-holt-5427128
What Readers Are Saying About Pragmatic Guide to Git
I’d heard a lot of the hype surrounding Git. It wasn’t until I read Travis’
book that I learned why people are so enthusiastic about it. Travis does a
great job explaining the power of Git in a digestible format.
Ivo Jansch
PHP evangelist, author, and founder, Egeniq.com
Git can be intimidating and frustrating to new users. Pragmatic Guide to Git
alleviates that pain with a straightforward, concise walk-through that arms
readers with exactly what they need to use Git productively.
Luigi Montanez
Software developer, Sunlight Labs
This book is a must-have for anyone using Git or just getting started with
Git. It has saved me time in finding the best practices for managing my Git
repositories and will sit on my bookshelf as the go-to resource for anything
Git.
John Mertic
Senior software engineer, SugarCRM
With two years of experience with Git, I thought I would have known most
everything in Pragmatic Guide to Git. After reading it cover to cover, I
learned that’s not the case. It’s a well-organized collection of useful Git
techniques for all audiences.
Luke Pillow
Software engineer, pillowfactory.org
Pragmatic Guide to Git
Travis Swicegood
Every precaution was taken in the preparation of this book. However, the publisher assumes no
responsibility for errors or omissions, or for damages that may result from the use of information
(including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team create better
software and have more fun. For more information, as well as the latest Pragmatic titles, please
visit us at http://www.pragprog.com.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any
form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the
prior consent of the publisher.
ISBN-10: 1-934356-72-7
ISBN-13: 978-1-934356-72-2
Printed on acid-free paper.
P1.0 printing, October 2010
Version: 2010-10-29
Contents
Acknowledgments 8
Introduction 9
Who Is This Book For? . . . . . . . . . . . . . . . . . . . . 9
How to Read This Book . . . . . . . . . . . . . . . . . . . . 10
How Git Is Different . . . . . . . . . . . . . . . . . . . . . . 12
The Git Workflow . . . . . . . . . . . . . . . . . . . . . . . 13
Online Resources . . . . . . . . . . . . . . . . . . . . . . . 16
I Getting Started 17
Report erratum
this copy is (P1.0 printing, October 2010)
CONTENTS 7
A Glossary 132
Index 136
Report erratum
this copy is (P1.0 printing, October 2010)
Acknowledgments
Like any book, this is the result of much more than an author such as me
sitting in front of their computer typing a bunch of words. Please give me a
few minutes to thank those involved in bringing this book to you.
First, I’d like to thank a reader of my first book, who shot me an email that
planted the seed that became this book.
Next, Dave, Andy, and the entire crew at Pragmatic Bookshelf have been
great to work with a second time. Both books I’ve written for them have
been gambles—first as a rookie author and then with this book as an author
charting the territory of a new format—and they haven’t blinked an eye.
My editor, Susannah Davidson Pfalzer, has been indispensable. She was al-
ways there with advice, tips, the occasional tough love, and an ever-optimistic
attitude; every author should be so lucky.
Reviewers of early drafts of this book provided me with a tremendous amount
of constructive feedback that helped shaped this book into what you’re hold-
ing in your hands (or looking at on your computer’s screen). Thanks to Joel
Clermont, Javier Collado, Geoff Drake, Chad Dumler-Montplaisir, Wayne
Huang, Michael Hunger, Ivo Jansch, Jerry Kuch, Johnathan Meehan, John
Mertic, Luigi Montanez, Karl Pfalzer, Luke Pillow, Christophe Portneuve,
Tom Sartain, Stefan Turalski, Tom Van Herreweghe, Matt Warren, and Nick
Watts.
No acknowledgments for a book on an open source tool would be complete
without acknowledging the work of the legion of volunteers who made the
project possible. A huge debt is owed by all of us who use Git to the nearly
700 people who have contributed to the project.
My family and friends, in particular my wife (whom I’m lucky enough to
count as both), have been amazing—as always. Without their support, and
that of the rest of my family and friends, this book would not have happened.
Introduction
The world of version control systems (VCSs) has undergone a major shift
over the past few years. Fast, reliable, and approachable distributed version
control systems (DVCSs) such as Git have burst onto the scene and changed
the landscape of open source software development and corporate software
workflows.
This book is your guide to this new paradigm. It’s not a complete reference;
instead, it focuses on getting you up and running quickly. Pragmatic Guide to
Git covers the 95 percent of Git that you’ll use at least once a week, as well
as a few tasks that will come in handy but aren’t used as often.
Git started when the license of VCS software that the Linux kernel used to
track changes was revoked. After investigating the other alternatives, Linus
Torvalds decided he could write a better version control system in a few weeks
than what currently existed, so he set off to do that.
Git, then in a very rough form, was the result of that two weeks of hacking
together some shell scripts back in the spring of 2005. Linus had to calculate
pieces of the commits by hand on the first few commits (commits are the
changes Git tracks for you). Since those original hand-rolled commits, Git
has become the leader in the field of DVCS.
Report erratum
this copy is (P1.0 printing, October 2010)
H OW TO R EAD T HIS B OOK 11
well as some of the more complex ways to handle merging and moving
branches around.
• Part VI, Working with the Repository’s History, introduces you to all
the history you’ve been generating. Using this information, you can
figure out what another developer (or maybe even you) was thinking
when you made a particular change.
• Part VII, Fixing Things, shows you how Git can help you fix things in
your repository—be that commits that need to be adjusted or finding
bugs in your code.
• Part VIII, Moving Beyond the Basics, introduces you to a few concepts
that don’t fit into the normal everyday workflow but are useful when
they’re needed.
There are diagrams throughout this book. Whenever you see a circle, it repre-
sents a commit—with the exception of Figure 2, on page 16, where the circles
represent repositories.
This matches the style used throughout the Git manual when it shows example
repository structures to explain commands. In addition to the standard graph-
ical diagrams throughout, in some places I’ve opted for a plain-text diagram
to introduce you to the Git manual diagram style.
Throughout the book you’ll see examples of the output you can expect Git
to generate for a given command. Keep in mind that your output won’t be
exactly the same because of the way Git keeps track of commit IDs—more
on that in a minute.
Several commands don’t generate any output after they run successfully,
though. For these commands, I include an empty prompt> after the success-
ful command to show that there is no output.
The first reference to each new term includes an explanation of what the term
means. If you read the book from start to finish, you’ll know all of the terms
from previous introductions to them.
Did you forget a term or are you using the book as a reference and not reading
it straight through? You’re covered there, too. You can refer to Appendix A,
on page 132; there you’ll get explanations of all the common—and some not
so common—jargon you’ll encounter in this book and in your adventures in
Git.
Report erratum
this copy is (P1.0 printing, October 2010)
H OW G IT I S D IFFERENT 12
Before we dive into the tasks, let’s talk a bit about Git and what makes it
unique.
Report erratum
this copy is (P1.0 printing, October 2010)
T HE G IT W ORKFLOW 13
Forking Is Good
For the longest time, forking a project was a bad thing. It drained resources
away from the main project, and merging changes between the two projects
was time-consuming when possible.
Git’s superior merge capabilities, rooted in its distributed nature, make merg-
ing changes from a “forked” repository trivial. In fact, the idea of forking is
so ingrained in the Git community that one of the largest Git communities
online, GitHub,2 is built around the concept. To offer your changes, you fork
a repository, commit your changes, and then ask the original developer to pull
your changes in through a pull request.
Instead of an indicator of a project suffering from internal strife, the num-
ber of forks on a repository is considered the sign of an active community
working on a project.
My Standard Workflow
My standard day working with Git goes something like this: I fetch all the
changes from the other developers on my team to make sure I’m working
with the latest code, and then I start working on the user stories I have for the
day. As I make changes, I create a handful of commits—a separate commit
for each change that I make.
2. http://github.com/
Report erratum
this copy is (P1.0 printing, October 2010)
T HE G IT W ORKFLOW 14
Make Changes
Fetch Changes
& Commit Them
from the Team
(repeat until done)
Share Changes
Review Commits
with the Team
Occasionally, I end up with several separate changes that all need to be com-
mitted. I’ll break out Git’s patch mode, stage, and finally commit each set of
changes separately.
Once I have the feature complete, I give the commits I’ve created a quick
review to make sure all the changes are necessary. At this point I look for
commits that can be combined and make sure they are in the most logical
order.
Finally, once I have those commits ready, I share those commits by push-
ing them (push is the term for sending commits to another repository) back
upstream to my public repository so the rest of the team can view them and
integrate them with their repositories.
Report erratum
this copy is (P1.0 printing, October 2010)
T HE G IT W ORKFLOW 15
Repository Layouts
The distributed nature of Git gives you a lot of flexibility in how you manage
your repositories. Every person on your team has their own private repository
—the repository that only that person can update. However, there are two
distinct ways to handle public repositories. For a visual explanation of these
layouts, see Figure 2, on the following page.
One method is the fully distributed model. In this, each developer has their
own public repository that the developer uses to publish their changes to.
All the other developers on the team then pull changes from everyone else’s
repositories to keep current.
In practice, most teams have a lead developer who is responsible for making
sure all the changes are integrated. This limits the number of repositories you
and your team have to pull changes from to one, but it increases the workload
on the person who has to integrate everyone’s changes.
Another method is the shared repository model, where all developers can push
to a shared repository. This resembles the standard centralized model and is
often adopted by teams when they first start using Git—it requires the least
amount of mental overhead when it comes to thinking about where a change
is shared.
You can mix both of these as well to create a hybrid solution. Use a shared
repository for all of the code that’s ready for production, and each developer
maintains their own public repository for sharing code that’s still a work in
progress. This is the model I’ve employed successfully at my company and
Report erratum
this copy is (P1.0 printing, October 2010)
Other documents randomly have
different content
CHAPITRE XXV.
Voici ma Réponse:
FIN.
Notes
ebookbell.com