Scott Chacon, Ben Straub
Format: PDF / Kindle (mobi) / ePub
Pro Git (Second Edition) is your fully-updated guide to Git and its usage in the modern world. Git has come a long way since it was first developed by Linus Torvalds for Linux kernel development. It has taken the open source world by storm since its inception in 2005, and this book teaches you how to use it like a pro.
Effective and well-implemented version control is a necessity for successful web projects, whether large or small. With this book you’ll learn how to master the world of distributed version workflow, use the distributed features of Git to the full, and extend Git to meet your every need.
Written by Git pros Scott Chacon and Ben Straub, Pro Git (Second Edition) builds on the hugely successful first edition, and is now fully updated for Git version 2.0, as well as including an indispensable chapter on GitHub. It’s the best book for all your Git needs.
What you’ll learn
• Effectively use Git, either as a programmer or a project leader
• Become a fluent Git user
• Master branching, using Git on the server, and on other systems
• Integrate Git in your development workflow
• Migrate programming projects from other SCMs to Git
• Extend Git for your personal project needs
• Effectively use GitHub
Who this book is for
This book is for all open source developers: you are bound to encounter Git somewhere in the course of your working life. Proprietary software developers will appreciate Git’s enormous scalability, since it is used for the Linux project, which comprises thousands of developers and testers.
Table of Contents
1. Getting Started
2. Git Basics
3. Git Branching
4. Git on the Server
5. Distributed Git
7. Git Tools
8. Customizing Git
9. Git and Other Systems
10. Git Internals
some of these undos. This is one of the few areas in Git where you may lose some work if you do it wrong. Changing Your Last Commit One of the common undos takes place when you commit too early and possibly forget to add some files, or you mess up your commit message. If you want to try that commit again, you can run commit with the --amend option: $ git commit --amend This command takes your staging area and uses it for the commit. If you’ve made no changes since your last commit (for
your work if the tip of the main repository has moved in the meantime and your commits no longer apply cleanly. For example, if you want to submit a second topic of work to the project, don’t continue working on the topic branch you just pushed up — start over from the main repository’s master branch: $ git checkout -b featureB origin/master $ (work) $ git commit $ git push myfork featureB $ (email maintainer) $ git fetch origin Now, each of your topics is contained within a silo —
master # Changes to be committed: # (use "git reset HEAD
three commit messages, or any of the commit messages in that group, you supply as an argument to git rebase -i the parent of the last commit you want to edit, which is HEAD~2^ or HEAD~3. It may be easier to remember the ~3 because you’re trying to edit the last three commits; but keep in mind that you’re actually designating four commits ago, the parent of the last commit you want to edit: $ git rebase -i HEAD~3 Remember again that this is a rebasing command — every commit included in the
more user-friendly commands are called “porcelain” commands. The book’s first eight chapters deal almost exclusively with porcelain commands. But in this chapter, you’ll be dealing mostly with the lower-level plumbing commands, because they give you access to the inner workings of Git and help demonstrate how and why Git does what it does. These commands aren’t meant to be used manually on the command line, but rather to be used as building blocks for new tools and custom scripts. When you run