What is the difference between ‘git pull’ and ‘git fetch’ ?

What is the difference between ‘git pull’ and ‘git fetch’  ?

Asked on December 14, 2018 in Git.
Add Comment

  • 3 Answer(s)

    Try this solution :

        In the simplest terms, git pull does a git fetch followed by a git merge.

        You can do a git fetch at any time to update your remote-tracking branches under refs/remotes/<remote>/.

        Sudden operation never changes any of your own local branches under refs/heads, and is safe to do without changing your working copy. I have even heard of people running git fetch periodically in a cron job in the background although I would not recommend doing this` 

       A git pull is what you would dgit-pull – Fetch from and integrate with another repository or a local branch

    Git documentation: git pull



    Answered on December 14, 2018.
    Add Comment

    Try this :

    • When you use pull, Git tries to automatically do your work for you. It is context sensitive,  so Git will merge any pulled commits into the branch you are currently working in. pull automatically merges the commits without letting you review them first. 
    • If you don’t closely manage your branches, you may run into frequent conflicts.
    • When you fetch, Git gathers any commits from the target branch that do not exist in your current branch and stores them in your local repository.However, it does not merge them with your current branch. 
    • This is particularly useful if you need to keep your repository up to date, but are working on something that might break if you update your files. To integrate the commits into your master branch, you use merge.


    Answered on December 14, 2018.
    Add Comment

    You can see this :

    It is important to contrast the design philosophy of git with the philosophy of a more traditional source control tool like SVN.

    Subversion was designed and built with a client/server model. There is a single repository that is the server, and several clients can fetch code from the server, work on it, then commit it back to the server. The assumption is that the client can always contact the server when it needs to perform an operation.

    Git was designed to support a more distributed model with no need for a central repository though you can certainly use one if you like. Also git was designed so that the client and the “server” don’t need to be online at the same time. Git was designed so that people on an unreliable link could exchange code via email, even. It is possible to work completely disconnected and burn a CD to exchange code via git.

    In order to support this model git maintains a local repository with your code and also an additional local repository that mirrors the state of the remote repository. By keeping a copy of the remote repository locally, git can figure out the changes needed even when the remote repository is not reachable. Later when you need to send the changes to someone else, git can transfer them as a set of changes from a point in time known to the remote repository.

    •  git fetch is the command that says “bring my local copy of the remote repository up to date.”
    • git pull says “bring the changes in the remote repository to where I keep my own code.”


    Usually git pull does this by doing a git fetch to bring the local copy of the remote repository up to date, and then merging the changes into your own code repository and possibly your working copy.

     There are often at least three copies of a project on your workstation. One copy is your own repository with your own commit history.

    sudden second copy is your working copy where you are editing and building. The third copy is your local “cached” copy of a remote repository.

    Answered on December 14, 2018.
    Add Comment

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.