Git Pull Not Pulling Everything
This article discusses the solution for git pull
not pulling everything. This is a guide for people who find themselves in a situation where a git pull
does not update everything in your local repository.
Perhaps a commit in the remote repository is not reflected in your local repo after a pull.
Fix git pull
Not Pulling Everything
The most common scenario is when the pull request does not reflect the latest commit from the remote repository. For easier context, let’s assume we are working on a project with a master
branch in the remote repository.
When we run a git pull
, the latest commit in the remote repository does not match the one in our local repo after the pull. How do we go about this?
At this juncture, you want to avoid invoking the merge functionality. It would be better to use the git fetch
command.
We can use git fetch
to reset our files to a specific commit. The following are the steps to resolve the issue.
First, we will fetch from the master
branch, and this branch contains the commit we need.
$ git fetch origin master
The git fetch
command is a less aggressive way of updating your HEAD
. Now, we can use the git reset
command to set our files as they are in the last commit on HEAD
.
$ git reset --hard FETCH_HEAD
The method above works with other branches. You can replace master
with any branch in your remote repository.
$ git fetch origin <branchname>
Conclusion
Your best resort is to use the git reset
command when a request does not pull everything. Make sure you fetch from the branch you want rather than pulling.
John is a Git and PowerShell geek. He uses his expertise in the version control system to help businesses manage their source code. According to him, Shell scripting is the number one choice for automating the management of systems.
LinkedIn