
Assume that we are at a starting point of our first diagram, and we have executed git pull -rebase. The next example will demonstrate how a rebase pull works. A -rebase option can be passed to git pull to use a rebase merging strategy instead of a merge commit. This example is one of a few git pull merging strategies. This commit is a new merge commit that contains the contents of remote A-B-C commits and has a combined log message. In the above diagram, we can see the new commit H. The pull process will then create a new local merge commit containing the content of the new diverged remote commits. git pull will fetch the diverged remote commits which are A-B-C. In this scenario, git pull will download all the changes from the point where the local and main diverged. Assume we have a repository with a main branch and a remote origin. To better demonstrate the pull and merging process let us consider the following example. Then a git merge is executed to merge the remote content refs and heads into a new local merge commit. The git pull command first runs git fetch which downloads content from the specified remote repository.

A new merge commit will be-created and HEAD updated to point at the new commit.


Once the content is downloaded, git pull will enter a merge workflow. In the first stage of operation git pull will execute a git fetch scoped to the local branch that HEAD is pointed at. The git pull command is actually a combination of two other commands, git fetch followed by git merge. Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows.
#GIT FETCH VS PULL ORIGIN UPDATE#
The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content.
