0 votes
47 views

 How will you differentiate between git pull and git fetch?

in Technology by (191k points)

1 Answer

0 votes

 Git pull command pulls all new commits from a specific branch in the central repository and makes the target branch in your local repository up-to-date.

Git fetch also aims at the same thing, however, its underlying functionality is a bit different. When you do a git fetch, all the new commits from a specific branch will be pulled in your central repository and these changes will be stored in a new branch in your local repository. This is called a fetched branch.

If you wish to see these changes in your target branch, then you need to perform a git merge after git fetch. The target branch will be updated with the latest changes only after merging it with the fetched branch.

So, a git pull brings the local branch up-to-date with its remote version, whereas a git fetch does not directly change your own local branch or working copy under refs/heads. Git fetch can be used to update your remote-tracking branches under refs/remotes/<remote>/.

In simple words, git pull is equal to git fetch followed by a git merge.

by (191k points)

Related questions

0 votes
0 answers 25 views
0 votes
1 answer 14 views
14 views asked Nov 4, 2020 in Technology by JackTerrance (191k points)
0 votes
1 answer 21 views
0 votes
1 answer 16 views
0 votes
1 answer 13 views
0 votes
1 answer 21 views
0 votes
1 answer 22 views
0 votes
1 answer 23 views
0 votes
1 answer 30 views
0 votes
1 answer 24 views
0 votes
1 answer 40 views
40 views asked Nov 4, 2020 in Technology by JackTerrance (191k points)
0 votes
1 answer 22 views
0 votes
1 answer 23 views
0 votes
1 answer 38 views
0 votes
1 answer 20 views
20 views asked Nov 4, 2020 in Technology by JackTerrance (191k points)
0 votes
1 answer 17 views
17 views asked Nov 4, 2020 in Technology by JackTerrance (191k points)
0 votes
1 answer 22 views
0 votes
1 answer 24 views
0 votes
1 answer 32 views
32 views asked Jan 8 in Technology by JackTerrance (191k points)
0 votes
1 answer 37 views
37 views asked Jan 8 in Technology by JackTerrance (191k points)
0 votes
1 answer 25 views
0 votes
1 answer 27 views
27 views asked Jan 8 in Technology by JackTerrance (191k points)
...