SECOND EDITION
Version Control with Git
Jon Loeliger and Matthew McCullough
Beijing
•
Cambridge
•
Farnham
•
Köln
•
Sebastopol
•
Tokyo
Downloa d f r o m W o w ! e B o o k < w w w.woweb o o k . c o m >
Version Control with Git, Second Edition
by Jon Loeliger and Matthew McCullough
Copyright © 2012 Jon Loeliger. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com.
Editor: Andy Oram
Production Editor: Iris Febres
Copyeditor: Absolute Service, Inc.
Proofreader: Absolute Service, Inc.
Indexer: Nancy Guenther on behalf of Potomac
Indexing, LLC
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrators: Robert Romano and Rebecca Demarest
May 2009: First Edition.
August 2012: Second Edition.
Revision History for the Second Edition:
2012-08-03 First release
See http://oreilly.com/catalog/errata.csp?isbn=9781449316389 for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Version Control with Git, the image of the image of a long-eared bat, and related
trade dress are trademarks of O’Reilly 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 O’Reilly 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 authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
ISBN: 978-1-449-31638-9
[LSI]
1344953139
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Background 1
The Birth of Git 2
Precedents 4
Timeline 6
What’s in a Name? 7
2. Installing Git . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Using Linux Binary Distributions 9
Debian/Ubuntu 9
Other Binary Distributions 10
Obtaining a Source Release 11
Building and Installing 12
Installing Git on Windows 13
Installing the Cygwin Git Package 14
Installing Standalone Git (msysGit) 15
3. Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
The Git Command Line 19
Quick Introduction to Using Git 21
Creating an Initial Repository 21
Adding a File to Your Repository 22
Configuring the Commit Author 24
Making Another Commit 24
Viewing Your Commits 25
Viewing Commit Differences 26
Removing and Renaming Files in Your Repository 26
Making a Copy of Your Repository 27
Configuration Files 28
iii
- 1
- 2
- 3
- 4
- 5
- 6
前往页