Skip to main content

Git Pull

git pull is a git command used to update the local version of a repository from a remote. It is one of the four commands that prompts network interaction by Git. By default, git pull does two things -

  1. Updates the current local working branch (currently checked out branch)
  2. Updates the remote tracking branches for all other branches.

git fetch updates remote tracking branches. git merge updates the current branch with the corresponding remote tracking branch. Using git pull, you get both parts of these updates.

Git Pull Syntax:

git pull <option> [<repository URL><refspec>...]

Git Pull Common Usage


  • git pull <remote> : Fetch the specified remote’s copy of the current branch and immediately merge it into the local copy.

    Example:

    git pull origin


  • git pull --no-commit <remote> : Similar to the default invocation, fetches the remote content but does not create a new merge commit.

    Example:

    git pull --no-commit origin


  • git pull --rebase <remote> : Same as the previous pull Instead of using git merge to integrate the remote branch with the local one, use [git rebase](https://git-scm.com/docs/git-rebase).

    Example:

    git pull --rebase origin


  • git pull --force : This option allows you to force a fetch of a specific remote tracking branch when using the <refspec> option that would otherwise not be fetched due to conflicts.

    Example:

    git pull --force


  • git pull --all : Fetch all remotes - this is handy if you are working on a fork or in another use case with multiple remotes.

    Example:

    git pull --all

You can learn more about the git pull command and its options in git-scm's documentation.