Integrating Remote Changes
Sooner or later, one of your teammates will probably also share his changes on your common remote repository. How can we properly integrate those changes?
Integrating Remote Changes featured image

Integrating Remote Changes

Sooner or later, one of your teammates will probably also share his changes on your common remote repository. Before integrating these changes into your local working copy, you might first want to inspect them:

$ git fetch origin
$ git log origin/master
Note

Since you will most likely encounter an "origin" remote in most of your projects, we will use this remote name in our examples in the rest of the book.

The "git log" command now shows you the commits that happened recently on the "master" branch of the remote called "origin".
If you decide you want to integrate these changes into your working copy, the "git pull" command is what you need:

$ git pull

This command downloads new commits from the remote and directly integrates them into your working copy. It's actually a "fetch" command (which only downloads data) and a "merge" command (which integrates this data into your working copy) combined.

As with the "git push" command: in case no tracking connection was established for your local HEAD branch, you will also have to tell Git from which remote repository and which remote branch you want to pull ("git pull origin master", e.g.). In case a tracking connection already exists, a vanilla "git pull" is sufficient.

The target of the integration, however, is independent of a tracking connection and is always the same: your local HEAD branch and, thereby, your working copy.

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.