Search code examples
gitversion-controlgit-pull

What is the difference between git pull and git reset --hard origin/<branch>?


I find the latter to be faster than the first, so I usually do that after git fetch whenever I need to sync my local branch with the remote. What is the difference?


Solution

  • The following commands:

    git fetch
    git reset --hard origin/<branch>
    

    will discard all local changes.

    Where as:

    git pull
    

    Which is exactly the same as:

    git fetch
    git merge origin/<branch>
    

    will attempt to preserve local changes.