Version Control with Git: Powerful tools and techniques for collaborative software development

Version Control with Git: Powerful tools and techniques for collaborative software development

Jon Loeliger, Matthew McCullough

Language: English

Pages: 456

ISBN: 1449316387

Format: PDF / Kindle (mobi) / ePub

Get up to speed on Git for tracking, branching, merging, and managing code revisions. Through a series of step-by-step tutorials, this practical guide takes you quickly from Git fundamentals to advanced techniques, and provides friendly yet rigorous advice for navigating the many functions of this open source version control system.

This thoroughly revised edition also includes tips for manipulating trees, extended coverage of the reflog and stash, and a complete introduction to the GitHub repository. Git lets you manage code development in a virtually endless variety of ways, once you understand how to harness the system’s flexibility. This book shows you how.

  • Learn how to use Git for several real-world development scenarios
  • Gain insight into Git’s common-use cases, initial tasks, and basic functions
  • Use the system for both centralized and distributed version control
  • Learn how to manage merges, conflicts, patches, and diffs
  • Apply advanced techniques such as rebasing, hooks, and ways to handle submodules
  • Interact with Subversion (SVN) repositories—including SVN to Git conversions
  • Navigate, use, and contribute to open source projects though GitHub













offline feature is a major reason developers prefer to use git svn instead of Subversion. • The working directory lacks .svn directories, but it does have the familiar .git di- rectory. Normally, when you check out a Subversion project, each subdirectory contains a .svn directory for bookkeeping. However, git svn does its bookkeeping in the .git directory, as Git always does. The git svn command does use an extra directory called .git/svn, which is described momentarily. • Even though you

checked out a branch named 1.5.x, the local branch has the standard Git name, master. Nonetheless, it still corresponds to the 1.5.x branch, revision 33142. The local repository also has a remote ref called git-svn, which is the parent of the local master branch. • The author’s name and email address in git log is atypical for Git. For example, the author is listed as hwright instead of the author’s real name, Hyrum Wright. Moreover, his email address a string of hex digits. Unfortunately,

provides a command to look up objects by a unique prefix of the object hash: $ git rev-parse 3b18e512d 3b18e512dba79e4c8300dd08aeb37f8e728b8dad Files and Trees Now that the “hello world” blob is safely ensconced in the object store, what happens to its filename? Git wouldn’t be very useful if it couldn’t find files by name. As mentioned earlier, Git tracks the pathnames of files through another kind of object called a tree. When you use git add, Git creates an object for the contents of

Chapter 4: Basic Git Concepts You can use the command git show --pretty=fuller to see additional details about a given commit. Commit objects are also stored in a graph structure, although it’s completely different from the structures used by tree objects. When you make a new commit, you can give it one or more parent commits. By following back through the chain of parents, you can discover the history of your project. More details about commits and the commit graph are given in Chapter

repository in /tmp/Depot. Perhaps more interesting is that your repository has two branches, one (master) with the new commit on it and the other (origin/master) that is tracking the remote repository. Pushing Your Changes Any change that you commit is completely local to your repository; it is not yet present in the remote repository. A convenient way to get your commit into the remote repo- sitory is to use the git push command: $ git push origin Counting objects: 4, done. Compressing

Download sample