GIT Tutorials

HOME

Git is a Distributed Version Control System (VCS) which is originally developed in 2005 by Linus Torvalds (Creator of Linux) and is open source, i.e. freely available to use. It is the most popular and most used version control tool right now. A staggering number of software projects rely on Git for version control, including commercial projects as well as open source. 

Chapter 1 How to install Git on Windows 10
Chapter 2 How to create a new Git Repository – git init Command
Chapter 3 How to clone a Git Repository – git clone – NEW
Chapter 4 How to stage changes in Git – git add Command
Chapter 5 How to unstage the changes in Git – git rm command
Chapter 6 How to commit changes in GIT – git commit command
Chapter 7 How to track commits in Git – git log command
Chapter 8 How to commit an empty folder in GIT – gitkeep
Chapter 9 How to ignore files in GIT – gitignore
Chapter 10 How to create a branch in GIT
Chapter 11 How to stash changes in GIT – git stash command
Chapter 12 How to push new local GIT Repository to GitLab
Chapter 13 How to change a remote repository’s URL using git?
Chapter 14 Git Cheat Sheet – NEW

How to pull changes from Remote Repository to Local Repository – git pull

HOME

The previous tutorial has explained about pushing the changes from Local GIT Repository to Remote GIT Repository. This tutorial explains the process of pulling the changes from Remote Repository to Local GIT Repository. I’ll use GitLab to make the changes.

What is git pull?

The git pull command fetches and downloads content from the remote repository and integrates changes into the local repository. The git pull command is called as the combination of git fetch followed by git merge.

This is my project in GitLab. If, you don’t have any project in GitLab, follow the below steps to create a GIT local Repository and push it to GitLab.

Step 1– To create a new Git local Repository, use git init. The details are mentioned in this tutorial – How to create a new Git Repository – git init Command.

Step 2 – To create a new project in GitLab, refer to this tutorial – How to create a new project in GitLab.

Step 3 – To push your GIT local repository to Gitlab, refer to this tutorial – How to push new local GIT Repository to GitLab.

Step 4 – Let’s add a new file in the Remote Repository directly using GitLab. Follow the steps shown below to add and commit a new .

Step 5 – This is a new file. I have provided name to this file as products.txt. Add the comment as commit message. Click the Commit changes button to commit this change.

Below image shows that new file – products.txt is committed to this project.

Step 6 – Go to the directory where local GIT Repository is saved. Right-click and click on Git Bash Here to open GitBash at that place.

Use the below command to see the list of files present in GIT Local Repository.

ls -a
git log

Type git log to see the list of commits present.

Step 7 – Type git pull command is used to pull the latest changes from Remote GIT Repository to local GIT Repository.

git pull origin master

This command says that pull the content from the “master” branch in the “origin” repo.

As the “git pull” command fetches and merges, we can see the newly added file named “products.txt” in my local repo.

Again use the below commands:

ls -a
git log

This shows that the new file – products.txt which was present in GitLab is now present in Git local Repository means latest change is pulled from GitLab to local Repository.

Congratulation!! We are able to pull the changes from Remote Repository to Local Repository. Happy Learning!!