How to properly get list of remotes files before the pull

I’ve see that I can get a list of files that will be pulled down by running the following commands (scripted):

branch_name=`git branch | grep ^\* | awk '{print $2}'`
git fetch
git diff --stat  origin/${branch_name}

This works fine. However, if I choose not to do the merge (or pull), and try again to check, I might not get any results (e.g. if I try too soon to check). Is there a way to clear the fetch and run this as a clean check every time?

  • How do I get the Maven Release Plugin to work with Git over SSH?
  • VSCode Git commands and tracking changes
  • Have git issue warnings
  • Disable password prompt for git pull, but not for push
  • git feature-branch workflow
  • How do I upgrade git submodules to the “gitfile” format?
  • Several local and remote git repositories with Netbeans
  • Migrate from Subversion to git, clone all branches and push through gitolite?
  • One Solution collect form web for “How to properly get list of remotes files before the pull”

    Like that :

    branch_name=`git branch | grep ^\* | awk '{print $2}'`
    old_commit=$(git rev-parse origin/${branch_name})
    git fetch
    git diff --stat origin/${branch_name}
    git update-ref refs/remotes/origin/${branch_name} $old_commit

    Should do the magic trick.
    It will “just” print the file changes in the upstream, and hopefully leave your repository completly unchanged.

    Git Baby is a git and github fan, let's start git clone.