Search code examples
gitgit-pullgit-fetch

git pull without updating remote


Suppose I have already run git fetch, and now I want to run git pull, to bring my local myBranch up-to-date with my origin\myBranch.

BUT!! in the mean time, after running the fetch, my internet connection has dropped :( Now, when I run git pull it fails, because it can't see remote. But I'd like to still do the local portion of the pull.

Is there a way to tell git pull to run without doing the initial git fetch?

NOTE: I could git reset --hard to update myBranch. But git pull doesn't always just do that.

I guess another way to phrase the question is "What second command satisfies: git pull = git fetch + git ???"?


Solution

  • In fact it depends on your configuration.

    In a default configuration, if you're on my_branch which has its upstream as origin/my_branch, then git pull can be considered as

    get fetch
    get merge origin/my_branch
    

    Configuration (or command line arguments) can change what will be merged. Configuration can also change the 2nd step from a merge into a rebase. So when you say

    "What second command satisfies: git pull = git fetch + git ???"?

    there's no one answer to what ??? is, but by default it would be merge.