Chapter 14. Keeping in sync

 

Collaborating with a software project that uses Git requires that you keep your repository in sync with this remote repository. The focus of this chapter is the command that helps you keep in sync: git pull.

git pull is the opposite operation of git push. You’ll learn how to use git pull to bring in changes that were made in the remote repository you’re tracking.

This is the step that keeps you in sync! You’ll also learn that git pull consists of two commands: git fetch and git merge. You learned about git merge in chapter 10, but knowing how it’s used in conjunction with git fetch will help you understand issues you might have with git pull.

14.1. Completing the cycle of collaboration

You’ve learned about clones (chapter 11) and how the git remote command (chapter 12) enables you to push to a remote (chapter 13). In figure 14.1, your clone (math.carol) can fetch (pull) from the remote (math.git), in addition to push.

Figure 14.1. A cycle of collaboration between math.carol and math.git

When you make a clone of a repository, Git creates a remote that enables your clone to both push and pull from the repository that you just cloned. The remote sets up a cycle of collaboration. In section 14.2, you’ll learn that git pull comprises two commands: git fetch and git merge. That’s why figure 14.1 labels the arrow from math.git to math.carol as fetch (pull).

14.2. Using git pull: a two-part operation

14.3. Merging a pull

14.4. Restricting pulls to fast-forwards only

14.5. Using git fetch and merge instead of pull

14.6. Lab

14.7. Commands in this chapter

sitemap