Pragmatic Version Control Using Git Travis Swicegood instant download
Pragmatic Version Control Using Git Travis Swicegood instant download
Swicegood download
https://ebookbell.com/product/pragmatic-version-control-using-
git-travis-swicegood-4645460
https://ebookbell.com/product/pragmatic-version-control-using-
subversion-2nd-ed-mike-mason-926532
https://ebookbell.com/product/pragmatic-version-control-using-
subversion-1st-edition-mike-mason-1021154
Agile Web Development With Rails 4th Edition Beta 10 Version Fourth
Edition Sam Ruby
https://ebookbell.com/product/agile-web-development-with-rails-4th-
edition-beta-10-version-fourth-edition-sam-ruby-2031134
https://ebookbell.com/product/practices-of-an-agile-developer-working-
in-the-real-world-1-book-version-p60august-2011-venkat-
subramaniam-38436440
Your Code As A Crime Scene Use Forensic Techniques To Arrest Defects
Bottlenecks And Bad Design In Your Programs 2 Book Version P10february
2024 Adam Tornhill
https://ebookbell.com/product/your-code-as-a-crime-scene-use-forensic-
techniques-to-arrest-defects-bottlenecks-and-bad-design-in-your-
programs-2-book-version-p10february-2024-adam-tornhill-56694874
https://ebookbell.com/product/pragmatic-testdriven-development-in-c-
and-net-write-loosely-coupled-documented-and-highquality-code-with-
ddd-using-familiar-tools-and-libraries-1st-edition-adam-tibi-46473346
https://ebookbell.com/product/pragmatic-thinking-and-learning-andrew-
hunt-47032922
https://ebookbell.com/product/pragmatic-judgments-in-direct-patient-
care-moral-theory-at-the-beginning-of-clinical-ethics-consultation-
bernhard-bleyer-49152564
https://ebookbell.com/product/pragmatic-studies-in-judaism-andrew-
schumann-editor-49454610
What readers are saying about Pragmatic Version Control
Using Git
If you are thinking of using Git, I highly recommend this book. If you
are not using a version control system (and code or create content on
a computer), put the book down, slap yourself, pick the book back up,
and buy it.
Jacob Taylor
Entrepreneur and Cofounder, SugarCRM Inc.
Not only has this book convinced me that Git has something to offer
over CVS and Subversion, but it has also showed me how I can benefit
from using it myself even if I’m using it alone in a CVS/Subversion
environment. I expect to be a full-time Git user soon after reading
this, which is hard to believe considering this is the first distributed
version control system I’ve ever looked at.
Chuck Burgess
2008 PEAR Group Member
Travis has done an excellent job taking a tricky subject and making it
accessible, useful, and relevant. You’ll find distributed version control
and Git much less mysterious after reading this book.
Mike Mason
Author, Pragmatic Version Control Using Subversion
Pragmatic Version Control
Using 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
ISBN-10: 1-934356-15-8
ISBN-13: 978-1-934356-15-9
Printed on acid-free paper.
P2.0 printing, March 2009
Version: 2009-4-20
Contents
Acknowledgments 9
Preface 10
Who’s This Book For? . . . . . . . . . . . . . . . . . . . . . . . 11
What’s in This Book? . . . . . . . . . . . . . . . . . . . . . . . . 11
Typographic Conventions . . . . . . . . . . . . . . . . . . . . . 13
Online Resources . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2 Setting Up Git 26
2.1 Installing Git . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.2 Configuring Git . . . . . . . . . . . . . . . . . . . . . . . 31
2.3 Using Git’s GUI . . . . . . . . . . . . . . . . . . . . . . . 33
2.4 Accessing Git’s Built-in Help . . . . . . . . . . . . . . . . 34
CONTENTS 6
II Everyday Git 50
Report erratum
this copy is (P2.0 printing, March 2009)
CONTENTS 7
Report erratum
this copy is (P2.0 printing, March 2009)
CONTENTS 8
IV Appendixes 157
C Bibliography 174
Index 175
Report erratum
this copy is (P2.0 printing, March 2009)
Acknowledgments
Although my name is on this book as the author, it is only here because
of a long list of people. Please indulge me while I take a moment to thank
them.
Thanks to Dave Thomas and Andy Hunt for taking the chance on a new
author. The entire team they’ve put together at Pragmatic Bookshelf is
amazing. I owe a special thanks to my editor, the ever helpful Susannah
Davidson Pfalzer.
I would also like to thank all of those who offered me feedback on the
book as it progressed through beta form. Especially helpful was the
great team of technical reviewers: Chuck Burgess, Pieter de Bie, Stu-
art Halloway, Junio Hamano, Chris Hartjes, Mike Mason, John Mertic,
Gary Sherman, Jacob Taylor, and Tommi “Tv” Virtanen. Thanks also
to the wonderful teams of developers and colleagues at SugarCRM and
Ning who supported me while I wrote this book.
Finally, I would like to thank my friends and family for their support
and understanding while I wrote this book. My wonderful wife, Meg,
put up with the late nights and “work weekends” with very little com-
plaining. Without her support, and that from the rest of my friends and
family, this book wouldn’t be here today.
Preface
Development teams around the globe are changing. They are dropping
their clunky, old, centralized version control systems (VCSs) in favor of
Git, which is a lightweight, distributed version control system (DVCS)
and relative newcomer to the version control world.
First here’s a quick overview: a version control system is like a bank
vault. You take your valuables—in our case as developers, these valu-
ables are the source code we write—and deposit them in the bank
for safekeeping.1 Each change you mark—or commit—is recorded, and
you can go back over the history just like you can review your bank
statement.
In the Git world, it’s like you walk around with your own vault that
has an automated teller attached right to it. You can fully disconnect
from everyone else, share what you want, and of course keep track of
your project’s history. The brainchild of Linus Torvalds, Git was orig-
inally developed to track changes made to the Linux kernel. Git has
matured from the original rough collection of scripts Linus created in a
few weeks into a rich toolkit. Its following strengths can help you as a
programmer:
• Distributed architecture: Disconnect completely, and work without
the distractions of an always-on Internet connection.
• Easy branching and merging: Creating branches is easy, cheap,
and fast, and unlike some version control systems, merging every-
thing back together—even multiple times—is a snap.
1. As I write this, we’re in the middle of a $700 billion bailout of the American banking
system, so maybe a bank isn’t the best of analogies. Don’t think about that part; just
think of banks the way they’re supposed to work.
W HO ’ S T HIS B OOK F OR ? 11
Report erratum
this copy is (P2.0 printing, March 2009)
W HAT ’ S IN T HIS B OOK ? 12
ates that there’s a full chapter explaining what branches are and
how to use them. With the first two chapters of Part II out of the
way, you’ll be ready to start exploring the history of changes you’ve
been creating. Chapter 6, Working with Git’s History, on page 80
covers that.
Chapter 7, Working with Remote Repositories, on page 100 introdu-
ces you to the concepts around sharing your work with others
through remote repositories. The “social” aspect of any version
control system is its killer feature, and Git is no different.
Once you know how to use Git and interact with other developers’
repositories, you’ll learn about some organizational techniques in
Chapter 8, Organizing Your Repository, on page 109 to keep your
repository sane.
Finally, we round out Part II with Chapter 9, Beyond the Basics,
on page 122, which introduces you to some commands you’ll find
useful for specialized situations.
These chapters all have lots of examples to follow along with, but
keep in mind they are jumping-off points for how to use Git to
work with your code’s history. Once you get more comfortable,
feel free to experiment.
• Part III is all about administration and is not required reading if
someone else on your team or in your company handles that for
you. Chapter 10, Migrating to Git, on page 136 shows you how to
handle migration to Git from other popular VCSs, and Chapter 11,
Running a Git Server with Gitosis, on page 147 teaches you how to
administer your public repositories with Gitosis.
• We close out with a few appendixes. In Appendix A, on page 158,
you’ll find a command reference so you can quickly find out how
to do common commands.
In Appendix B, on page 167, you’ll find coverage of some extra
tools—some that ship with Git and some of which you have to
install yourself—and links to online resources.
Finally, in Appendix C, on page 174, you’ll find information on
other books that are referenced throughout this one.
Report erratum
this copy is (P2.0 printing, March 2009)
T YPOGRAPHIC C ONVENTIONS 13
Typographic Conventions
A few typographical conventions are used throughout this book. They
are as follows:
Git Refers to the program as a whole when capitalized.
git Refers to the command you run on the command
line.
italic Signifies new concepts.
files and directories Are displayed in this font.
prompt> Comes before something you should type. Longer
commands may be broken up into several lines
with a \ at the end of each line. They can be typed
as one line. They’re broken up in the book only so
they fit on the page.
Online Resources
Each chapter in Part II starts with a repository that looks like your
repository does if you follow along with each of the examples throughout
the book. If you skip ahead, you can get a copy of the repository by
cloning it from GitHub. You can find the repositories on GitHub from
my profile:
http://github.com/tswicegood
The command you need to get the current repository is listed at the
start of each chapter.
The book’s web page on pragprog.com3 is a great jumping-off point for
what’s going on with the book. From there you can drop me a note on
the forums or make suggestions or corrections on the errata page.
At this point, I’m sure you’re teeming with questions. So, without fur-
ther ado, let’s jump into it!
3. http://www.pragprog.com/titles/tsgit
Report erratum
this copy is (P2.0 printing, March 2009)
Part I
14
Chapter 1
Report erratum
this copy is (P2.0 printing, March 2009)
W HAT S HOULD Y OU S TORE ? 17
Report erratum
this copy is (P2.0 printing, March 2009)
W ORKING T REES 18
Report erratum
this copy is (P2.0 printing, March 2009)
T RACKING P ROJECTS , D IRECTORIES , AND F ILES 19
A DVCS such as Git requires that you share your changes with other
developers in order for them to have access to them. This is done by
pushing the changes to an upstream repository.
An upstream repository is a public repository that you and possibly
other developers all push changes to. Pushing is what you do when you
want to send your data to another repository so it can be shared with
other developers.
Pushing changes is just half of what you need to do to stay in sync. You
also have to fetch changes to get the latest updates from other members
on your team.
There are two steps to retrieving changes from a remote Git repository.
First, you fetch them. That creates a copy of the remote repository’s
changes for you. This step is sort of like the reverse of pushing. Instead
of sending changes to another repository, you ask the remote repository
to send you the changes it has.
Next, you merge those changes into your local history. Git provides
tools that help you merge changes. Since you normally want to fetch
and merge changes at the same time, Git provides a way to do both
in one step through a process called pulling. Pulling is similar to an
update command in Subversion or CVS.
Git is fully distributed, though. You can push and pull changes to and
from multiple repositories. Working with remote repositories is a core
part of fully understanding how Git works. We’ll cover it fully in Chap-
ter 7, Working with Remote Repositories, on page 100.
Report erratum
this copy is (P2.0 printing, March 2009)
Another Random Document on
Scribd Without Any Related Topics
CHAPTER II
FOR the purposes of simplicity and brevity the main argument of The Great
Illusion assumed the relative permanence of the institution of private
property in Western society, and the persistence of the tendency of
victorious belligerents to respect it, a tendency which had steadily grown in
strength for five hundred years. The book assumed that the conqueror
would do in the future what he has done to a steadily increasing degree in
the past, especially as the reasons for such policy, in terms of self-interest,
have so greatly grown in force during the last generation or two. To have
argued its case in terms of non-existent and hypothetical conditions which
might not exist for generations or centuries, would have involved
hopelessly bewildering complications. And the decisive reason for not
adding this complication was the fact that though it would vary the form of
the argument, it would not effect the final conclusion.
As already explained in the first part of this book (Chapter II) this war
has marked a revolution in the position of private property and the relation
of the citizen to the State. The Treaty of Versailles departs radically from
the general principles adhered to, for instance, in the Treaty of Frankfurt;
the position of German traders and that of the property of German citizens
does not at all to-day resemble the position in which the Treaty of Frankfurt
left the French trader and French private property.
The fact of the difference has already been entered into at some length. It
remains to see how the change affects the general argument adopted in The
Great Illusion.
It does not affect its final conclusions. The argument ran: A conqueror
cannot profit by ‘loot’ in the shape of confiscations, tributes, indemnities,
which paralyse the economic life of the defeated enemy. They are
economically futile. They are unlikely to be attempted, but if they are
attempted they will still be futile.[119]
Events have confirmed that conclusion, though not the expectation that
the enemy’s economic life would be left undisturbed. We have started a
policy which does injure the economic life of the enemy. The more it
injures him, the less it pays us. And we are abandoning it as rapidly as
nationalist hostilities will permit us. In so far as pre-war conditions pointed
to the need of a definitely organised international economic code, the
situation created by the Treaty has only made the need more visible and
imperative. For, as already explained in the first Part, the old
understandings enabled industry to be built up on an international basis; the
Treaty of Versailles and its confiscations, prohibitions, controls, have
destroyed those foundations. Had that instrument treated German trade and
industry as the Germans treated French in 1871 we might have seen a
recovery of German economic life relatively as rapid as that which took
place in France during the ten years which followed her defeat. We should
not to-day be faced by thirty or forty millions in Central and Eastern Europe
without secure means of livelihood.
The present writer confesses most frankly—and the critics of The Great
Illusion are hereby presented with all that they can make of the admission—
that he did not expect a European conqueror, least of all Allied conquerors,
to use their victory for enforcing a policy having these results. He believed
that elementary considerations of self-interest, the duty of statesmen to
consider the needs of their own countries just emerging from war, would
stand in the way of a policy of this kind. On the other hand, he was under
no illusions as to what would result if they did attempt to enforce that
policy. Dealing with the damage that a conqueror might inflict, the book
says that such things as the utter destruction of the enemy’s trade
could only be inflicted by an invader as a means of punishment costly to
himself, or as the result of an unselfish and expensive desire to inflict
misery for the mere joy of inflicting it. In this self-seeking world it is not
practical to assume the existence of an inverted altruism of this kind.—(p.
29.)
Because of the ‘interdependence of our credit-built finance and industry’
the confiscation by an invader of private property, whether stocks, shares,
ships, mines, or anything more valuable than jewellery or furniture—
anything, in short, which is bound up with the economic life of the people
—would so react upon the finance of the invader’s country as to make the
damage to the invader resulting from the confiscation exceed in value the
property confiscated—(p. 29).
Speaking broadly and generally, the conqueror in our day has before him
two alternatives: to leave things alone, and in order to do that he need not
have left his shores; or to interfere by confiscation in some form, in which
case he dries up the source of the profit which tempted him—(p. 59).
All the suggestions made as to the economic futility of such a course—
including the failure to secure an indemnity—have been justified.[120]
In dealing with the indemnity problem the book did forecast the
likelihood of special trading and manufacturing interests within the
conquering nation opposing the only condition upon which a very large
indemnity would be possible—that condition being either the creation of a
large foreign trade by the enemy or the receipt of payment in kind, in goods
which would compete with home production. But the author certainly did
not think it likely that England and France would impose conditions so
rapidly destructive of the enemy’s economic life that they—the conquerors
—would, for their own economic preservation, be compelled to make loans
to the defeated enemy.
Let us note the phase of the argument that the procedure adopted renders
out of date. A good deal of The Great Illusion was devoted to showing that
Germany had no need to expand territorially; that her desire for overseas
colonies was sentimental, and had little relation to the problem of providing
for her population. At the beginning of 1914 that was certainly true. It is not
true to-day. The process by which she supported her excess population
before the War will, to put it at its lowest, be rendered extremely difficult of
maintenance as the result of allied action. The point, however, is that we are
not benefiting by this paralysis of German industry. We are suffering very
greatly from it: suffering so much that we can be neither politically nor
economically secure until this condition is brought to an end. There can be
no peace in Europe, and consequently no safety for us or France, so long as
we attempt by power to maintain a policy which denies to millions in the
midst of our civilisation the possibility of earning their living. In so far as
the new conditions create difficulties which did not originally exist, our
victory does but the more glaringly demonstrate the economic futility of our
policy towards the vanquished.
An argument much used in The Great Illusion as disproving the claims
made for conquest was the position of the population of small States. ‘Very
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
ebookbell.com