difference between git fetch and git pull

0 votes
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,030 points
2,456 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
1 answer

What is the difference between git fetch and git pull?

Hii @kartik, The main difference between git fetch ...READ MORE

answered Mar 3 in Git & GitHub by Niroj
• 6,740 points
64 views
0 votes
2 answers

difference between git remote and git clone

git remote add just creates an entry in ...READ MORE

answered Aug 7, 2018 in Git & GitHub by Kalgi
• 51,830 points
1,942 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
• 10,660 points
207 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
• 9,500 points

closed Nov 25, 2019 by Sirajul 110 views
+13 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,400 points
412 views
0 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
3,515 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
• 9,940 points
113 views