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
• 15,220 points
1,256 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

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
• 41,470 points
761 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 in Git & GitHub by Ali
• 10,430 points
122 views
0 votes
1 answer

Git pull vs Git Fetch

The objective of both these commands is ...READ MORE

answered Apr 26, 2018 in Git & GitHub by DragonLord999
• 8,380 points
276 views
0 votes
1 answer
+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,380 points
177 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
1,854 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,850 points
41 views