How To List Files That Will Be Pushed In Git

The aim of this page📝is to find files that are
a) committed
b) not pushed yet
c) will be pushed with git push command

It is simplified for checking just branches that are set as matching already (e.g. master <> origin/master)

1. notes

git diff --stat --cached [remote/branch]
  • For the master branch, it would be
git diff --stat --staged origin/master
  • --stat generates only diffstat
  • --staged is synonym with --cached

… view the changes you staged for the next commit relative to the named <commit> … if you do not give <commit>, it defaults to HEAD (pavol: HEAD of the provided <path>, i.e. HEAD of your<remote branch>)
--stagedis a synonym of --cached

  • <path> is the upstream tracking branch you are running diff against
  • you can keep committing and the difference between local/remote just gets aggregated in the “report” above — git log would keep commits separated. You can be 5 commits ahead and you get a single table listing all the files that will fly to the repo with the next git push

2. example

▶ git diff --stat --staged origin/master

powershell/rdbldev.ps1 | 2 +-
productivity/ | 21 +++++++-- | 11 ++++- | 54
.../ | 32 +} | 10 ++--
python/ | 6 +--
sicp/ | 39
sicp/ | 27 +++++++++++
sicp/ | 5 +-

10 files changed, 183 insertions(+), 24 deletions(-)

3. links

Technical Support Engineer of a Data Collection Platform (Snowplow Analytics)