Git Fetch vs Pull

What is the difference between a git fetch and a git pull ? In a nutshell, A git pull operation updates a local branch (under refs/heads) with its remote version. It will at the same time update the other remote branches (under refs/remotes).

From the official Git documentation, a git pull is just a git fetch operation followed by a get merge FETCH HEAD command.

Read: How to install Git on Ubuntu 18.04

The git fetch operation does not change the user’s own local branches (under refs/heads) which means that it can be done without changing your current working copy. After the git fetch, the remote branches are called origin/branch_name instead of branch_name.

Read: How to discard changes in Git

Note that a git push operation does never merge (either manual or automatic). If there are merge conflicts, get pull has to be applied followed by a resolution of potential merge conflicts locally before finally pushing back to the remote branch.

For more information, refer to the official Git documentation here.

Answer due to Greg Hewgill .

 


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.

 

Marianne elanotta

As a graduate in communication technologies, Marianne likes to share the latest technological advances in various fields. She likes to program in Java OO and Javascript and prefers to work on Open source operating systems. She likes to play chess and computer games in her spare time along with her 2 kids.

Leave a Reply