difference between git fetch and git pull

+1 vote
Hey, so I’ve recently started working with git and I’ve had the confusion as to when to use fetch and when pull. can someone help me out?
Jun 27, 2018 in Git & GitHub by Hannah
• 18,570 points
5,928 views

1 answer to this question.

0 votes

Both fetch and pull are used to download data from the remote repository. Which is appropriate, depends on your need.

command for fetch in git is

                $ git fetch origin

Fetch only downloads the data from the repository it does not integrate with the files you're currently working with. It only gives a view of all the things happened in the remote repository. Fetch is considered harmless as it never manipulates or spoils anything. You can fetch as many times as you want without disturbing your current working files.

  Pull on the other hand downloads the data and integrates it with the current working files.

 command for pull is

                $ git pull origin master

 So when you want to update your current HEAD branch with the latest changes from the remote you always use pull. Since git pull, merges the remote repository changes with the local ones it has a few things to be kept in mind

 ->Merge conflict: That is when you try to merge files where either two people make changes to the same line in the same file or when two people add files with same name unknowingly etc.

->Its recommended to start a git pull only after committing the files you currently working with or save them temporarily and have git pull with a clean working copy.

answered Jun 27, 2018 by anonymous

Related Questions In Git & GitHub

0 votes
2 answers

What is the difference between git fetch and git pull?

Hii.. I HOPE BELOW ANSWER  MAY HELP YOU- In ...READ MORE

answered Jul 18, 2020 in Git & GitHub by anonymous
8,312 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 11, 2020 in Git & GitHub by anonymous
21,527 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 3, 2019 in Git & GitHub by Ali
• 11,360 points
3,000 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,610 points

closed Nov 25, 2019 by Sirajul 736 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,530 views
+2 votes
1 answer
+1 vote
4 answers

GIT plugin in jenkins not able to connect to GIT repository

This looks like a git configuration issue, ...READ MORE

answered Oct 25, 2018 in Git & GitHub by Alia
18,880 views
0 votes
1 answer

How to forcefully commit a file to Git even if the file is ruled as unchanged?

This is simple, just follow the below ...READ MORE

answered Jul 11, 2018 in Git & GitHub by Sophie may
• 10,610 points
12,593 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP