Conteúdo do Curso
GitHub Fundamentals
GitHub Fundamentals
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
:
Obrigado pelo seu feedback!