The git pull
command is used to pull or fetch the remote branches. After the fetch operation, the local repository is updated in order to align with the fetched remote repository. The pulling/fetching remote branch is a regular and daily task in order to get the latest updates made by other developers or 3rd parties to the local system. Actually, the git pull
command is the combination of the two commands git fetch
and git merge
which are also two steps of the pull/fetch operation. In this tutorial, we examine different ways to pull or fetch remote branches to the local repository.
Pull/Fetch Remote Branch with “git pull”
The “git pull” command is used to pull/fetch the remote branch to the local and update the local repository. In order to fetch the remote repository should be provided as a parameter. The syntax of the “git pull” command is like below.
git pull REPOSITORY
Pull/Fetch Remote Branch without Creating New Merge Commit
By default, the pulling/fetching remote branch creates a new merge commit. But we can prevent this by using the --no-commit
option with the “git pull” command.
git pull --no-commit REPOSITORY
Pull/Fetch Remote Branch By Rebasing
Alternatively, we can pull/fetch the remote branch without creating a new merge commit with the rebase feature. The --rebase
option is used to pull/fetch the remote branch without creating a new merge commit.
git pull --rebase
Debug/Verbose Pull/Fetch For Remote Branch
The pull or fetch operation generally creates a lot of downloads and actions under the hood. But these downloads are not displayed during operation by default. If we want to review these downloads and operations we can make the pull/fetch of the remote branch verbosely by enabling the debug mode. The --verbose
option is used to enable debugging.
git pull --verbose