What is the difference between git fetch and git pull

0 votes
When should we use and what is the main difference between them??
Mar 3, 2020 in Git & GitHub by kartik
• 37,490 points
1,174 views

2 answers to this question.

0 votes

Hii @kartik,

The main difference between git fetch and git pull is:

  • If you do a git fetch it will just fetch all the changes in the remote repository (Github) and move the origin/master pointer to HEAD. Meanwhile your local branch master will keep pointing to where it has.
  • If you do a git pull, it will do basically fetch (as explained previously) and merge any new changes to your master branch and move the pointer to HEAD.

So, git pull=git fetch + merge.

answered Mar 3, 2020 by Niroj
• 82,560 points
0 votes

Hii..

I HOPE BELOW ANSWER  MAY HELP YOU-

In the simplest terms, Git pull does a git fetch followed by a git merge.

You can do a git fetch at any time to update your remote-tracking branches under refs/remotes/<remote>/.

This operation never changes any of your own local branches under refs/heads, and is safe to do without changing your working copy. I have even heard of people running git fetch periodically in a cron job in the background (although I wouldn't recommend doing this).

A git pull is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

From the Git documentation for git pull:

In its default mode, git pull is shorthand for git fetch followed by git merge 

FETCH_HEAD.

Regards

 SRI

answered Jul 17, 2020 by anonymous

Related Questions In Git & GitHub

+1 vote
1 answer

difference between git fetch and git pull

Both fetch and pull are used to ...READ MORE

answered Jun 27, 2018 in Git & GitHub by anonymous
4,473 views
0 votes
2 answers

What's the difference between git push and git commit?

I installed ubuntu on vagrant and gave ...READ MORE

answered Jan 2, 2019 in Git & GitHub by Ali
• 11,300 points
974 views
0 votes
0 answers

Difference between git rebase and git merge? Which among them is better to use?

Difference between git rebase and git merge? ...READ MORE

Nov 25, 2019 in Git & GitHub by anonymous
• 19,580 points

closed Nov 25, 2019 by Sirajul 258 views
0 votes
3 answers

difference between git remote and git clone

HI.... GIT REMOTE add just creates an entry in ...READ MORE

answered Jul 10, 2020 in Git & GitHub by anonymous
5,492 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
949 views
+2 votes
1 answer
0 votes
1 answer