Search code examples
gitgithubgit-fetch

How to preview changes before git pull


I want to check the changes that will done to the files after I run git pull. I know we use git fetch to retrieve new objects from remote repository without changing local repository. But how can I view these changes in editor ?


Solution

  • Assuming that all your local modifications are commited, one way would be to do:

    git fetch origin
    
    # To see local changes as the "new" version
    git diff origin/yourbranch HEAD
    
    # Or to see remote changes as the "new" version
    git diff HEAD origin/yourbranch
    

    This will compare your local repository (currently HEAD) with the remote content origin/yourbranch.