git pull

In this post, I will show you how to pull a project from the GitHub repository to your local machine, how to run the git pull command, and when & why to use git pull. Please note that it’s different from the git clone that many beginners mess up with.

Also, you will see common mistakes & errors while pushing to the remote origin and how to solve the issue with git pull (in the video).

Let’s get started.

How to use git pull to get the latest copy of your project?

The command for pulling a repository is as follows:

git pull origin master

git pull origin master, pulling the latest copy from the remote origin to local machine

The above command will pull the latest copy of the project from the remote origin (GitHub, Bitbucket, etc) to your computer.

But why & when to use the git pull command?

Let’s assume that you work on a team and you went on vacation for 5 days. When you came back from vacation, you see that your coworkers made lots of progress on the project. They also pushed their progress to the repository (GitHub/Bitbucket/etc).

What should you do now?

This is the situation where the “git pull” comes in very handy. Instead of calling your team members and asking for the latest code, you can easily grab the latest changes to your computer using the git pull origin master command.

That means if your local copy does not match the remote origin (repository), you have to grab the latest copy of the project using this command/feature.

Git push rejected (error: failed to push some refs to remote origin URL)

git push rejected because remote contains work

If the remote origin contains work then you won’t be able to push. To fix the issue and push from your local machine, you have to take a copy of the recent changes (pull) and then you will be able to push to the origin master.

For more detailed instructions & explanation, see the video below:

If you still have any issues with pushing from your local machine or problem with the git pull or any questions, let me know.

Learn more about Git


Git pull comes into play when you need to grab the latest changes from the remote origin. It also becomes very handy when you work in a team. Because everyone can work on their end and push the changes, and anyone can grab the latest copy of the repository/project.

Also, if you create a file from GitHub, you won’t be able to push code from your local machine or computer until you pull the latest copy from the remote origin.