in Technology by

 How will you differentiate between git pull and git fetch?

1 Answer

0 votes
by

 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.

Related questions

0 votes
    How will you differentiate between git pull and git fetch?...
asked Nov 4, 2020 in Technology by JackTerrance
0 votes
    What is the difference between 'git pull' and 'git fetch'?...
asked Jan 7, 2021 in Technology by JackTerrance
0 votes
    What is the difference between git pull and git fetch?...
asked Nov 2, 2020 in Technology by JackTerrance
0 votes
    Explain the difference between git fetch and git pull....
asked Oct 4, 2020 in Technology by Editorial Staff
0 votes
    How will you differentiate between Git and GitHub?...
asked Nov 4, 2020 in Technology by JackTerrance
0 votes
    When you run git fetch from my local repo, will it update your local code and target branch? (1)Yes, the command ... new commits and keep them in a separate branch in local repo...
asked Oct 26, 2020 in Technology by JackTerrance
0 votes
    When you run git fetch from my local repo, will it update your local code and target branch? A. Yes, the command ... new commits and keep them in a separate branch in local repo...
asked Dec 20, 2022 in Education by JackTerrance
0 votes
    When you run git fetch from your local repo, it will update your local changes in working area? A. True – ... It updates local repo only and does not affect the working area...
asked Dec 20, 2022 in Education by JackTerrance
0 votes
    I cloned a Git repository, which contains about five branches. However, when I do git branch I only see one of ... staging * etc... Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    How can we force “git pull” to overwrite local files?...
asked Jan 7, 2021 in Technology by JackTerrance
0 votes
    I have a project consisting of a huge amount of data. Because of its size, I can't use a remote GIT repo and push/pull ... -ProjectGit | | |-objects |-project1 | |-refs | |-.git...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    My git workspace is dirty, there are some local modifications. When I use the command git pull origin master it ... Ansible git module? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have created a branch named dev. I have done a pull request to send dev code to master, when I do ... to resolve these conflicts. Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    a. What is abstraction? How it is different from inheritance? b.Differentiate between compiler and interpreter. c. ... final keyword. Select the correct answer from above options...
asked Dec 5, 2021 in Education by JackTerrance
0 votes
    a. What is abstraction? How it is different from inheritance? b.Differentiate between compiler and interpreter. c. ... final keyword. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
...