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

Course Content

GitHub Fundamentals

GitHub Fundamentals

1. Introduction to GitHub
2. Basic Interaction with Remotes
3. More Advanced Workflows

book
Pulling 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 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.

Note
Note

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:

Note
Note

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

question mark

What does the git pull command do?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 6

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

course content

Course Content

GitHub Fundamentals

GitHub Fundamentals

1. Introduction to GitHub
2. Basic Interaction with Remotes
3. More Advanced Workflows

book
Pulling 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 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.

Note
Note

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:

Note
Note

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

question mark

What does the git pull command do?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 6
We're sorry to hear that something went wrong. What happened?
some-alt