logo资料库

Git Pocket Guide.pdf

第1页 / 共233页
第2页 / 共233页
第3页 / 共233页
第4页 / 共233页
第5页 / 共233页
第6页 / 共233页
第7页 / 共233页
第8页 / 共233页
资料共233页,剩余部分请下载后查看
Cover
Copyright
Table of Contents
Preface
What Is Git?
Goals of This Book
Conventions Used in This Book
Unix
Shell
Command Syntax
Typography
Using Code Examples
Safari® Books Online
How to Contact Us
Acknowledgments
Chapter 1. Understanding Git
Overview
Terminology
Branches
Sharing Work
The Object Store
Blob
Tree
Commit
Tag
Object IDs and SHA-1
Security
Where Objects Live
The Commit Graph
Refs
Related Commands
Branches
The Index
Merging
Merging Content
Merging History
Push and Pull
Notes
Chapter 2. Getting Started
Basic Configuration
Personal Identification
Text Editor
Commit ID Abbreviation
Pagination
Color
Cryptographic Keys
Command Aliases
Getting Help
References
Creating a New, Empty Repository
Selected Options
Importing an Existing Project
Ignoring Files
Syntax of “Ignore Patterns”
Chapter 3. Making Commits
Changing the Index
Adding a New File
Adding the Changes to an Existing File
Adding Partial Changes
Shortcuts
Removing a File
Renaming a File
Unstaging Changes
Making a Commit
Commit Messages
What Makes a Good Commit?
Shortcuts
Empty Directories
A Commit Workflow
Chapter 4. Undoing and Editing Commits
Changing the Last Commit
Double Oops!
Discarding the Last Commit
Discarding Any Number of Commits
Undoing a Commit
Partial Undo
Editing a Series of Commits
Conflicts
The exec Action
Chapter 5. Branching
The Default Branch, master
Making a New Branch
Switching Branches
Uncommitted Changes
Untracked Files
Losing Your Head
Deleting a Branch
Renaming a Branch
Chapter 6. Tracking Other Repositories
Cloning a Repository
Clones and Hard Links
Bare Repositories
Reference Repositories
Local, Remote, and Tracking Branches
Synchronization: Push and Pull
Pulling
Pushing
Push Defaults
Pull with Rebase
Notes
Access Control
Chapter 7. Merging
Merge Conflicts
Resolving Merge Conflicts
Notes
Details on Merging
Merge Tools
Notes
Custom Merge Tools
Merge Strategies
Why the Octopus?
Reusing Previous Merge Decisions
Chapter 8. Naming Commits
Naming Individual Commits
Commit ID
Ref Name
Names Relative to a Given Commit
Names Relative to the Reflog
The Upstream Branch
Matching a Commit Message
Following Chains
Addressing Pathnames
Naming Sets of Commits
Chapter 9. Viewing History
Command Format
Output Formats
Defining Your Own Formats
Notes
Limiting Commits to Be Shown
Regular Expressions
Reflog
Decoration
Date Style
Listing Changed Files
Showing and Following Renames or Copies
Detecting Copies
Rewriting Names and Addresses: The “mailmap”
Shortening Names
Searching for Changes: The “pickaxe”
Showing Diffs
Color
Word Diff
Comparing Branches
Displaying Sides
Showing Notes
Commit Ordering
History Simplification
Related Commands
git cherry
git shortlog
Chapter 10. Editing History
Rebasing
Undoing a Rebase
Importing from One Repository to Another
Importing Disconnected History
Importing Linear History
Importing Nonlinear History
Commit Surgery: git replace
Keeping It Real
The Big Hammer: git filter-branch
Examples
Notes
Chapter 11. Understanding Patches
Applying Plain Diffs
Patches with Commit Information
Chapter 12. Remote Access
SSH
HTTP
Storing Your Username
Storing Your Password
References
Chapter 13. Miscellaneous
git cherry-pick
git notes
git notes Subcommands
git grep
Combining Regular Expressions
What to Search
What to Show
How to Match
git rev-parse
git clean
git stash
Subcommands
git show
git tag
Deleting a Tag from a Remote
Following Tags
Backdating Tags
git diff
git diff
git diff --staged
git diff
git diff
www.iebukes.com www.iebukes.com
> m o c . k o o b e w o w w w w < k o o B e ! . w o W m o r f d a o n w o D l Git Pocket Guide Richard E. Silverman www.iebukes.com www.iebukes.com
Git Pocket Guide by Richard E. Silverman Copyright © 2013 Richard E. Silverman. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebasto‐ pol, 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.safaribookson line.com). For more information, contact our corporate/institutional sales de‐ partment: 800-998-9938 or corporate@oreilly.com. Editors: Mike Loukides and Meghan Blanchette Production Editor: Melanie Yarbrough Copyeditor: Kiel Van Horn Proofreader: Linley Dolby Indexer: Judith McConville Cover Designer: Randy Comer Interior Designer: David Futato Illustrator: Rebecca Demarest June 2013: Revision History for the First Edition: First Edition 2013-06-24: First release 2013-07-10: Second release See http://oreilly.com/catalog/errata.csp?isbn=9781449325862 for release de‐ tails. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Git Pocket Guide, 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 author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN: 978-1-449-32586-2 [M] www.iebukes.com
Table of Contents Preface Chapter 1: Understanding Git Overview The Object Store Object IDs and SHA-1 Where Objects Live The Commit Graph Refs Branches The Index Merging Push and Pull Chapter 2: Getting Started Basic Configuration Creating a New, Empty Repository Importing an Existing Project Ignoring Files Chapter 3: Making Commits www.iebukes.com ix 1 2 6 11 15 16 17 19 22 24 26 33 33 39 41 42 47 iii
Changing the Index 47 Making a Commit 52 Chapter 4: Undoing and Editing Commits 57 Changing the Last Commit 58 Discarding the Last Commit 61 Undoing a Commit 62 Editing a Series of Commits 64 Chapter 5: Branching 69 The Default Branch, master 70 Making a New Branch 70 Switching Branches 72 Deleting a Branch 75 Renaming a Branch 78 Chapter 6: Tracking Other Repositories 79 Cloning a Repository 79 Local, Remote, and Tracking Branches 84 Synchronization: Push and Pull 86 Access Control 94 Chapter 7: Merging 95 Merge Conflicts 98 Details on Merging 105 Merge Tools 107 Custom Merge Tools 108 Merge Strategies 109 Why the Octopus? 111 Reusing Previous Merge Decisions 112 Chapter 8: Naming Commits 115 iv | Table of Contents
Naming Individual Commits 115 Naming Sets of Commits 123 Chapter 9: Viewing History 127 Command Format 127 Output Formats 128 Defining Your Own Formats 130 Limiting Commits to Be Shown 132 Regular Expressions 133 Reflog 134 Decoration 134 Date Style 135 Listing Changed Files 136 Showing and Following Renames or Copies 138 Rewriting Names and Addresses: The “mailmap” 139 Searching for Changes: The “pickaxe” 142 Showing Diffs 142 Comparing Branches 144 Showing Notes 146 Commit Ordering 146 History Simplification 147 Related Commands 147 Chapter 10: Editing History 149 Rebasing 149 Importing from One Repository to Another 153 Commit Surgery: git replace 159 The Big Hammer: git filter-branch 162 Notes 166 Chapter 11: Understanding Patches 167 Applying Plain Diffs 169 Table of Contents | v
> m o c . k o o b e w o w w w w < k o o B e ! . w o W m o r f d a o n w o D l Patches with Commit Information 170 Chapter 12: Remote Access 173 SSH 173 HTTP 177 Storing Your Username 177 Storing Your Password 178 References 179 Chapter 13: Miscellaneous 181 git cherry-pick 181 git notes 182 git grep 184 git rev-parse 187 git clean 187 git stash 188 git show 191 git tag 191 git diff 194 git instaweb 195 Git Hooks 196 Visual Tools 197 Submodules 197 Chapter 14: How Do I…? 199 …Make and Use a Central Repository? 199 …Fix the Last Commit I Made? 200 …Edit the Previous n Commits? 200 …Undo My Last n Commits? 200 …Reuse the Message from an Existing Commit? 201 …Reapply an Existing Commit from Another Branch? 201 …List Files with Conflicts when Merging? 201 vi | Table of Contents
收藏