Preface

Audience

Although some familiarity with revision control systems will be good background material, a reader who is not familiar with any other system will still be able to learn enough about basic Git operations to be productive in a short while. More advanced readers should be able to gain insight into some of Git’s internal design and thus master some of its more powerful techniques.

The main intended audience of this book should be familiar and comfortable with the Unix shell, basic shell commands, and general programming concepts.

Assumed Framework

Almost all examples and discussions in this book assume the reader has a Unix-like system with a command-line interface. The author developed these examples on Debian and Ubuntu Linux environments. The examples should work under other environments, such as Mac OS X or Solaris, but the reader can expect slight variations.

A few examples require root access on machines where system operations are needed. Naturally, in such situations, you should have a clear understanding of the responsibilities of root access.

Book Layout and Omissions

This book is organized as a progressive series of topics, each designed to build upon concepts introduced earlier. The first 11 chapters focus on concepts and operations that pertain to one repository. They form the foundation for more complex operations on multiple repositories covered in the final 10 chapters.

If you already have Git installed or have even used it briefly, then you may not need the introductory and installation information in the first two chapters, nor even the quick tour presented in the third chapter.

The concepts covered in Chapter 4 are essential for a firm grasp on Git’s object model. They set the stage and prepare the reader for a clearer understanding of many of Git’s more complex operations.

Chapters 5 through 11 cover various topics in more detail. Chapter 5 describes the index and file management. Chapters 6 and 10 discuss the fundamentals of making commits and working with them to form a solid line of development. Chapter 7 introduces branches so that you may manipulate several different lines of development from your one local repository. Chapter 8 explains how Git derives and presents diffs.

Git provides a rich and powerful ability to join different branches of development. The basics of branch merging and resolving merge conflicts are covered in Chapter 9. A key insight into Git’s model is to realize that all merging performed by Git happens in your local repository in the context of your current working directory. Chapters 10 and 11 expose some operations for altering, storing, tracking, and recovering daily development within your development repository.

The fundamentals of naming and exchanging data with another, remote repository are covered in Chapter 12. Once the basics of merging have been mastered, interacting with multiple repositories is shown to be a simple combination of an exchange step plus a merge step. The exchange step is the new concept covered in this chapter and the merge step is covered in Chapter 9.

Chapter 13 provides a more philosophical and abstract coverage of repository management in the large. It also establishes a context for Chapter 14 to cover patch handling when direct exchange of repository information isn’t possible using Git’s native transfer protocols.

The next four chapters cover advanced topics of interest: the use of hooks (Chapter 15), combining projects and multiple repositories into a superproject (Chapter 16 and Chapter 17), and interacting with Subversion repositories (Chapter 18).

Chapters 19 and 20 provide some advanced examples and clever tips, tricks, and techniques that may help transform you into a true Git guru.

Finally, Chapter 21 introduces GitHub and explains how Git has enabled a creative, social development process around version control.

Git is still evolving rapidly because there is an active developer base. It’s not that Git is so immature that you cannot use it for development; rather, ongoing refinements and user interface issues are being enhanced regularly. Even as this book was being written, Git evolved. Apologies if I was unable to keep up accurately.

I do not give the command gitk the complete coverage that it deserves. If you like graphical representations of the history within a repository, you should explore gitk. Other history visualization tools exist as well, but they are not covered here either. Nor am I able to cover a rapidly evolving and growing host of other Git-related tools. I’m not even able to cover all of Git’s own core commands and options thoroughly in this book. Again, my apologies.

Perhaps, though, enough pointers, tips, and direction can be found here to inspire readers to do some of their own research and exploration!

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.

Tip

This icon signifies a useful hint or a tip.

Warning

This icon indicates a warning or caution.

Note

This icon indicates a general note.

Furthermore, you should be familiar with basic shell commands to manipulate files and directories. Many examples will contain commands such as these to add or remove directories, copy files, or create simple files:

    $ cp file.txt copy-of-file.txt
    $ mkdir newdirectory
    $ rm file
    $ rmdir somedir
    $ echo "Test line" > file
    $ echo "Another line" >> file

Commands that need to be executed with root permissions appear as a sudo operation:

    # Install the Git core package

    $ sudo apt-get install git-core

How you edit files or effect changes within your working directory is pretty much up to you. You should be familiar with a text editor. In this book, I’ll denote the process of editing a file by either a direct comment or a pseudocommand:

    # edit file.c to have some new text

    $ edit index.html

Using Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: Version Control with Git by Jon Loeliger and Matthew McCullough. Copyright 2012 Jon Loeliger, 978-1-449-31638-9.

If you feel your use of code examples falls outside fair use or the permission given previously, feel free to contact us at .

Safari® Books Online

Note

Safari Books Online (www.safaribooksonline.com) is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:

http://oreil.ly/VCWG2e

To comment or ask technical questions about this book, send email to:

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments

This work would not have been possible without the help of many other people. I’d like to thank Avery Pennarun for contributing substantial material to Chapters 15, 16, and 18. He also contributed some material to Chapters 4 and 9. His help was appreciated. I’d like to thank Matthew McCullough for the material in Chapters 17 and 21, assorted suggestions, and general advice. Martin Langhoff is paraphrased with permission for some repository publishing advice in Chapter 13, and Bart Massey’s tip on keeping a file without tracking is also used with permission. I’d like to publicly thank those who took time to review the book at various stages: Robert P. J. Day, Alan Hasty, Paul Jimenez, Barton Massey, Tom Rix, Jamey Sharp, Sarah Sharp, Larry Streepy, Andy Wilcox, and Andy Wingo. Robert P. J. Day, thankfully, took the time to review both editions of the book front to back.

Also, I’d like to thank my wife Rhonda, and daughters Brandi and Heather, who provided moral support, gentle nudging, Pinot Noir, and the occasional grammar tip. And thanks to Mylo, my long-haired dachshund who spent the entire writing process curled up lovingly in my lap. I’d like to add a special thanks to K. C. Dignan, who supplied enough moral support and double-stick butt-tape to keep my behind in my chair long enough to finish this book!

Finally, I would like to thank the staff at O’Reilly as well as my editors, Andy Oram and Martin Streicher.

Attributions

Linux® is the registered trademark of Linus Torvalds in the United States and other countries.

PowerPC® is a trademark of International Business Machines Corporation in the United States, other countries, or both.

UNIX is a registered trademark of The Open Group in the United States and other countries.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.111.24