Welcome to Day 2 of Git Masterclass 💪
Today, we will learn about the difference between git pull
and git fetch
- all in under 3 mins ⚡️
What is the difference between git pull
and git fetch
?
This is one of the most commonly asked interview questions, and you need to learn this not just for interviews but for the effective use of Git in daily work.
What is git fetch
?
Suppose you are working on a repository and there are changes made to the remote branch which you need to have in your local branch as well.
Let's see what git fetch
does in this scenario -
Now you can see in the tracking log that the incoming changes mention the new changes brought in from the remote repository.
But.. notice that these changes are simply visible in the log, but not yet MERGED with your local files.
What does this mean?
This means that git fetch
only shows the incoming new changes from the remote repository and does not actually merge them with your local files.
How to merge remote changes to local in Git?
This is where we use the git pull
command - it executes two commands in one go, namely - git fetch
and git merge
.
You can see here that all the remote changes are now merged with your local files.
That concludes Day 2 of our Git Masterclass. If you found this helpful, then make sure to watch the video version of it right here - Day 2 of learning Git with Sarthak
Also, don't forget to subscribe to our newsletter for weekly tips and insight into tech and development - Bitfumes Weekly
See you in the next one 🚀
Top comments (0)