DEV Community

Cover image for Git Masterclass - Day 2
2 1 1 1 1

Git Masterclass - Day 2

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 -

git fetch

git tracking log

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.

incoming changes

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.

git pull

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 ๐Ÿš€

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

๐Ÿ‘ฅ Ideal for solo developers, teams, and cross-company projects

Learn more

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay