pull command retrieves and integrates changes from another repository or local branch. This command is like a combination of the
merge commands and is often used for the following:
- Move code from a remote machine or repository to a local one.
- Retrieve code from a repository hosting service like GitHub.
pull command is a
fetch command followed by a
Pulling a repository allows programmers to access code from a remote backup and make it available on their local machine. It is also used when collaborating with others in order to keep the local code up to date with the team’s current version.
git pull <remote-name> <branch-name>
This will move the code from
<remote-name> currently in branch
<branch-name>, and move it to the branch checked out locally on the user’s computer.
How to Pull
Prerequisites to pulling from a remote repository include:
Being inside of the local repository (if not, the next step will return an error)
Being inside of the correct branch and having a clean
git statusin that branch:$ git checkout new-feature-branch$ git statusOn branch new-feature-branchnothing to commit, working tree clean
Having a valid remote repository set. In this case, the remote repository is named
originand can be found at the URL
https://github.com/CodeNinja/product-dev:$ git remote -vorigin https://github.com/CodeNinja/product-dev.git (fetch)origin https://github.com/CodeNinja/product-dev.git (push)
At this stage, pulling can be accomplished with a valid remote and branch name:
git pull origin new-feature-branch
When the pull completes, it will display a message like this:
remote: Counting objects: 5, done.remote: Compressing objects: 100% (3/3), done.remote: Total 5 (delta 2), reused 0 (delta 0), pack-reused 0Unpacking objects: 100% (5/5), done.From https://github.com/CodeNinja/product-dev.git* branch new-feature-branch -> FETCH_HEAD
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.