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 -
- Updates the current local working branch (currently checked out branch)
- 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.
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.
git pull --no-commit origin
git pull --rebase <remote>: Same as the previous pull Instead of using
git mergeto integrate the remote branch with the local one, use
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.
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.
git pull --all
You can learn more about the
git pullcommand and its options in git-scm's documentation.