Chapter 11. Cloning

 

Cloning, the act of making a physical copy of a Git repository, is the first step in collaborating with others. You’ll be covering collaboration over this and the next three chapters. When you clone a repository, you make an exact replica of that repository. The clone has a special reference to the original repository. This reference lets your clone push (send) and pull (receive) changes to and from the original repository. You’ll study this special reference (called a remote) in the next chapter, and then read about push and pull in chapters 13 and 14.

In this chapter, you’ll make a copy of your repository by using git clone. You’ll examine your clone and figure out how to confirm that it’s an exact copy of the original, where it stores your branches, and how it knows about the original repository. All this will help you become oriented after you run git clone on an existing repository. Finally, you’ll cover a special type of clone called the bare directory that lets you set up collaboration, as in figure 11.1. This is a technique that this book uses to teach collaboration on a single machine, and it’s the basis for server-based Git systems like GitHub.

Figure 11.1. A set of repositories collaborating with one another

It won’t take you long to learn these operations, which are the foundation of Git collaboration.

11.1. Cloning: making copies locally

11.2. Working with the bare directory

11.3. Listing files in the repo by using git ls-tree

11.4. Lab

11.5. Further exploration

11.6. Commands in this chapter

sitemap