Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Pulling Changes | Basic Interaction with Remotes
GitHub Fundamentals

Pulling ChangesPulling Changes

As a matter of fact, fetching and then immediately merging changes is an extremely common scenario. That's why Git provides a single command, git pull, that combines these two operations and integrates the changes into the current branch.

Let's now pull the remote changes made by John into our local repository:

As you can see, the output of this command is basically a combination of the outputs of the git fetch and git merge commands.

In case there were also changes on the remote main branch not merged with john/test, a fast-forward merge would be performed into the local main branch (provided that there were no conflicts).

You can also run the git remote show origin command to see that there is indeed a remote john/test branch, but our local repository doesn't have the corresponding local branch.

Let's create a local branch for it by running the git checkout command:

Let's break down what has just happened:

  1. We switched to the john/test branch;
  2. Git automatically copied the remote branch's contents into the local branch;
  3. The working tree has been updated to reflect the contents of the john/test branch.

We can easily verify that we are on this branch and that it is up-to-date with its remote counterpart by looking at the latest commit:

The -n flag specifies the number of commits to display. In this example, -n 1 tells Git to show only the most recent commit.

Everything was clear?

Section 2. Chapter 6
course content

Course Content

GitHub Fundamentals

Pulling ChangesPulling Changes

As a matter of fact, fetching and then immediately merging changes is an extremely common scenario. That's why Git provides a single command, git pull, that combines these two operations and integrates the changes into the current branch.

Let's now pull the remote changes made by John into our local repository:

As you can see, the output of this command is basically a combination of the outputs of the git fetch and git merge commands.

In case there were also changes on the remote main branch not merged with john/test, a fast-forward merge would be performed into the local main branch (provided that there were no conflicts).

You can also run the git remote show origin command to see that there is indeed a remote john/test branch, but our local repository doesn't have the corresponding local branch.

Let's create a local branch for it by running the git checkout command:

Let's break down what has just happened:

  1. We switched to the john/test branch;
  2. Git automatically copied the remote branch's contents into the local branch;
  3. The working tree has been updated to reflect the contents of the john/test branch.

We can easily verify that we are on this branch and that it is up-to-date with its remote counterpart by looking at the latest commit:

The -n flag specifies the number of commits to display. In this example, -n 1 tells Git to show only the most recent commit.

Everything was clear?

Section 2. Chapter 6
some-alt