Features Of Git Fetch And Git Pull command

Reading Time: 3 minutes

Git Fetch command

Git fetch command works on the local repository where it only fetches the data from the remote repository to have a look what all the changes has been done by the developers or what all new commits are made by them.

So that it updates the developer to work.

But, it doesn’t makes a copy of the work instead it allows the developer to view the work for his acknowledge.

Git Pull command

Git Pull command works on the local repository where it makes a copy of the remote repository into your local repository.

So that it can edit or works on the work for the updating.

It makes a copy of the work and allows the developer to contribute to the work for the better actions.  

Uses of the commands

The term pull is used to receive data from GitHub. It fetches and merges changes from the remote server to your working directory. The git pull is used to pull a repository.

Figure: Pull

The term git fetch is used to just fetch the data from remote repository without accessing the repository just to make a mirror for view.

Figure: Fetch

Implementation and Working

Working of fetch command with multiple option:

Syntax :

To fetch from the remote repository:

$ git fetch< repository URL>  
figure 1.1

To fetch a specific branch:

$ git fetch <branch URL><branch name>  
figure: 1.2

To fetch all branch :

$ git fetch -all
figure: 1.3

To synchronize the local repository :

$ git fetch origin
figure : 1.4

Working of pull command with multiple options as:

Syntax:

To pull the repository by:

$ git pull <options><remote>/<branch-name>  
figure: 2.1

Areas to use

Git fetch can be use where we only have to look what the developers updated in the remote repository.

Git Pull can be use where we want to contribute in the work by cloning and using the project.

References

https://www.javatpoint.com/git-fetch

https://www.javatpoint.com/git-pull

https://www.atlassian.com/git/tutorials/syncing/git-fetch

https://git-scm.com/docs/git-pull

Written by 

VIkas Vashisth is a Software Consultant and having experience in DevOps. He loves to know about new technology.