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
course content

Зміст курсу

GitHub Fundamentals

Fetching and Merging Remote ChangesFetching 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:

The untracked .DS_Store file I have here was automatically created by MacOS. If you also have this file and want to remove it, you can use the rm .DS_Store command. However, to prevent it from being tracked in future projects, consider adding .DS_Store to your .gitignore file.

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?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 2. Розділ 4
course content

Зміст курсу

GitHub Fundamentals

Fetching and Merging Remote ChangesFetching 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:

The untracked .DS_Store file I have here was automatically created by MacOS. If you also have this file and want to remove it, you can use the rm .DS_Store command. However, to prevent it from being tracked in future projects, consider adding .DS_Store to your .gitignore file.

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?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 2. Розділ 4
some-alt