Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Syncing the Repositories | More Advanced Workflows
GitHub Fundamentals

Syncing the RepositoriesSyncing the Repositories

As mentioned in the previous chapter, we need to sync our local branch with the remote repository. To do this, we should run the git pull command:

When we ran the git pull command, Git fetched updates but noticed our local and remote branches have diverged, meaning there are changes on both branches that need to be reconciled. Git couldn't proceed because it needs to know how to handle these differences, so let's set the merge option and run the git pull command again:

We will cover the rebase operation later in this course.

Git tried to automatically merge the local and remote changes to README.md, but ecnountered a merge conflict. Let's take a look at the commit tree, which indicates where the divergence and conflicts have occurred:

Resolving the Conflict

As you can see, our current local commit and the commit in the remote main branch share a common ancestor, but they diverge, leading to the merge conflict that we need to resolve. To do it, we'll open the README.md file in the Vim editor:

What we can do to resolve this conflict is enter insert mode by pressing i, remove the conflict markers, and combine these changes in the following way:

Next, you should press the Escape key, type :wq, and press the Enter key to save the changes and exit Vim. Now, to finish the merge, the README.md file must be added to the staging area and then committed using the respective commands:

After running the git commit command, the default text editor will open (most likely, Vim). You can either leave the default commit message and exit Vim the same way as we just did, or you can edit the message and then exit.

Finally, we can safely run the git push command and verify that the three-way merge was successful by displaying the commit tree:

Let's break down what we did in these two chapters:

  1. We simulated collaboration by making changes both locally and remotely to the README.md file;
  2. We first committed a change directly to the remote repository, then made a different change locally;
  3. When we tried to push our local changes, we encountered a conflict because the remote repository had new updates;
  4. To resolve this, we pulled the changes from the remote repository, which resulted in a merge conflict;
  5. We then manually resolved the conflict in the README.md file using the Vim editor, committed the resolved changes, and successfully pushed the final updates to the remote repository.

Everything was clear?

Section 3. Chapter 2
course content

Course Content

GitHub Fundamentals

Syncing the RepositoriesSyncing the Repositories

As mentioned in the previous chapter, we need to sync our local branch with the remote repository. To do this, we should run the git pull command:

When we ran the git pull command, Git fetched updates but noticed our local and remote branches have diverged, meaning there are changes on both branches that need to be reconciled. Git couldn't proceed because it needs to know how to handle these differences, so let's set the merge option and run the git pull command again:

We will cover the rebase operation later in this course.

Git tried to automatically merge the local and remote changes to README.md, but ecnountered a merge conflict. Let's take a look at the commit tree, which indicates where the divergence and conflicts have occurred:

Resolving the Conflict

As you can see, our current local commit and the commit in the remote main branch share a common ancestor, but they diverge, leading to the merge conflict that we need to resolve. To do it, we'll open the README.md file in the Vim editor:

What we can do to resolve this conflict is enter insert mode by pressing i, remove the conflict markers, and combine these changes in the following way:

Next, you should press the Escape key, type :wq, and press the Enter key to save the changes and exit Vim. Now, to finish the merge, the README.md file must be added to the staging area and then committed using the respective commands:

After running the git commit command, the default text editor will open (most likely, Vim). You can either leave the default commit message and exit Vim the same way as we just did, or you can edit the message and then exit.

Finally, we can safely run the git push command and verify that the three-way merge was successful by displaying the commit tree:

Let's break down what we did in these two chapters:

  1. We simulated collaboration by making changes both locally and remotely to the README.md file;
  2. We first committed a change directly to the remote repository, then made a different change locally;
  3. When we tried to push our local changes, we encountered a conflict because the remote repository had new updates;
  4. To resolve this, we pulled the changes from the remote repository, which resulted in a merge conflict;
  5. We then manually resolved the conflict in the README.md file using the Vim editor, committed the resolved changes, and successfully pushed the final updates to the remote repository.

Everything was clear?

Section 3. Chapter 2
some-alt