← All languages
Git command of the day
Random

pull

Fetch from and integrate with another repository or a local branch.

Description

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. It is essentially a combination of git fetch followed by git merge.

When you run git pull, Git first runs git fetch to download the content from the specified remote repository, then runs git merge to merge the remote content into a new local merge commit. If there are conflicts, you will need to resolve them manually.

The git pull command can also be configured to use rebase instead of merge by passing the --rebase flag. This replays your local commits on top of the fetched commits, resulting in a linear project history.

Arguments

NameDescriptionOptional
remote The name of the remote to pull from. Defaults to origin. Yes
branch The remote branch to pull. Defaults to the tracking branch. Yes
--rebase Rebase the current branch on top of the upstream branch after fetching. Yes
--no-commit Perform the merge but do not create an automatic merge commit. Yes

Example

git pull
git pull origin main
git pull --rebase origin main

Reference