What is the difference between 'git pull' and 'git pull origin master'?

First, let us understand what git pull is:

  • 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. The git pull command is a combination of git fetch and git merge. git pull will download the content from the remote repository. Once the content is downloaded, git merge will merge the content to your local repository. A new merge commit will be created and HEAD updated to point at the new commit.

  • Now that we know what git pull does, when we do git pull origin master, it simply fetches a copy of the master branch from the original repository, and merges it with the current branch that you have checked out.

For more information, you can go to this link.


Remember, a pull is a fetch and a merge.

  • git pull origin master fetches commits from the master branch of the origin remote (into the local origin/master branch), and then it merges origin/master into the branch you currently have checked out.

  • git pull only works if the branch you have checked out is tracking an upstream branch. For example, if the branch you have checked out tracks origin/master, git pull is equivalent to git pull origin master

Tags:

Git