gitgit-pull

Git Merge - Difference between pull and merge


In my .gitconfig I have rebase set as default pull option. I am trying to understand what's the difference between

git merge origin/develop

vs.

git pull origin develop

All I currently understand is git pull origin develop pulls the branch develop from origin (remote) into current branch. But so does git merge origin/develop (or, does it)?

Thanks,


Solution

  • git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch.

    The command

    git pull <remote> <branch>
    

    is really just the same as

    git fetch <remote>
    git merge <remote>/<branch>
    

    So there is no practical difference between

    git pull origin master
    

    and

    git fetch origin
    git merge origin/master
    

    In order to understand more check this documentation Pull and Merge