What is the difference between Git Fetch and Git Pull?

Learn about two very confusing git commands often asked in an interview

Both Fetch and Pull commands get the latest changes from a remote repository.


Fetch

git fetch origin

It only downloads the latest changes and doesn't update your current local repository.

Imagine fetch as a refresh activity on your local repository which lets you know if there are any more changes from your last pull.

Pull

git pull origin master

It pulls the latest changes AND merges those changes in your local repository

Imagine git pull doing git fetch + applying the changes in your repository.


Thank you for reading.

I hope this has been helpful. Let me know your feedback in the comments. I would love to connect with you at Twitter | LinkedIn | GitHub

No Comments Yet