Git fetch and pull commands

We use several GIT commands to work with the remote repositories.Two of the commands useful for updating the remote repository are fetch and pull.

Git fetch

While using GIT we work with repositories. Repositories can be on our local system or on a remote system.We make changes in our local repository and updates the remote repository with our changes.
The main difference between fetch and pull is that fetch does not merge remote repository changes while pull fetches and also merges the remote repository changes.

Git fetch command is used as:

1.Change to local repository which you want to fetch.Use the following command to do this:
git branch local-branch-name

2.execute the following command.Use the following command to fetch the remote branch.
git fetch remote-branch-name

Git pull

Git pull command executes the Git fetch command followed by the Git merge command.Merge is used to merge changes from one branch into another branch.

Git pull command is used as:

git pull remote-branch-name local-branch-name

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *