In this article, we will learn How to Pull the changes from the remote repository to the working area by using Git Pull command.
Total Views: 5528
In this article, we will learn How to Pull the changes from the remote repository to the working area by using the Git Pull command. Git Pull command is used to update the local repository from a remote repository. It also updates the remote-tracking branches for the all-other branches.
As you can see in the above image, Git pull command is actually a combination of “Git Fetch” followed by the “Git Merge” command. For demonstration, I already have a cloned repository on my local system.
How to Clone a repository from GitHub?
On the remote repository, there are some changes in the master branch which are not yet pulled in the local repository.
Use the “git pull” command to incorporate the changes from a remote repository. You can clearly see that during the pull, git fetch and merge files using fast-forward approach.
In case any remote changes overlapped with the local uncommitted changes, then merging will be canceled. It’s always recommended to commit or Stash the changes before pulling requests from the remote server.
In case you have multiple remote configurations in your project then “git pull” might not provide enough information for pulling the files from the remote repository. In that case, use “git pull <Remote_Repository> <RefSpec>”. RefSpec can be the name of the branch in the remote repository, tag, or even the collection of the refs corresponding to the remote-tracking branch. In the below example, I am using “git pull origin master” to pull the data from the master branch of the remote named origin.
There are several options that can be passed along with the “git pull” command. For example, -v for verbose which provides the detailed message logs while pulling the files from the remote repository, -q for the quiet, -r for the rebase which incorporates the changes by rebasing rather than merging, etc. Use the “git pull -h” command to check the list of available options and configurations.