Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Fetching and Merging Remote 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
Fetching and Merging Remote Changes

Fetching Remote Changes

To update our local view of the remote changes, we use the git fetch command. This command retrieves the commits from the remote repository to the corresponding remote branches on our system, allowing us to review what has been committed by others.

After fetching, the content is available in our remote branch but not yet in our local branch. Essentially, we simply updated the data about the current state of the remote repository. Let's now take a look at the commits in the remote main branch by running the following command:

This inspection shows that the remote branch origin/main points to the latest commit, whereas our local main branch is still on an earlier commit. If we now run git status, it will indicate that our local branch is behind its remote counterpart:

Merging Remote Changes

To synchronize and integrate the changes, we can merge the origin/main into our local main branch using the following command:

After the merge, Git will confirm that the changes have been integrated through a fast-forward merge, and it lists the new test.txt file. Checking the git log on our branch will now show that our main branch is up to date with origin/main:

After fetching changes from a remote repository, what command do you use to integrate these changes into your local branch?

After fetching changes from a remote repository, what command do you use to integrate these changes into your local branch?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

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