Skip to content

Commit 402fbd5

Browse files
committed
difference between git fetch and git pull
1 parent 69d2459 commit 402fbd5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Let two people have below branches on which they work.
2+
3+
master
4+
dev
5+
person A
6+
person B
7+
8+
We both keep working on our branches i.e. person A or person B (working on same project).
9+
10+
#### How B can take the latest changes which A has done, from dev to his branch person B
11+
12+
```
13+
git checkout dev
14+
15+
git pull dev
16+
```
17+
18+
### What's the difference between git fetch and git pull?
19+
20+
Before we talk about the differences between these two commands, let's stress their similarities: both are used to download new data from a remote repository.
21+
22+
**git fetch** really only downloads new data from a remote repository - but it doesn't integrate any of this new data into your working files.
23+
24+
`git pull origin master`
25+
26+
git pull, in contrast, is used with a different goal in mind: to update your current HEAD branch with the latest changes from the remote server. This means that pull not only downloads new data; it also directly integrates it into your current working copy files. This has a couple of consequences:
27+
28+
Since "git pull" tries to merge remote changes with your local ones, a so-called "merge conflict" can occur. Check out our in-depth tutorial on How to deal with merge conflicts for more information.
29+
Like for many other actions, it's highly recommended to start a "git pull" only with a clean working copy. This means that you should not have any uncommitted local changes before you pull. Use Git's Stash feature to save your local changes temporarily.

0 commit comments

Comments
 (0)