Is there a way to see what would be pushed if I did a git push
command?
What I\'m picturing is something like the \"Files Changed\" tab of Github\'s \"p
You probably want to run git difftool origin/master...
. that should show the unified diff of what is on your current branch that is not on the origin/master branch yet and display it in the graphical diff tool of your choice. To be most up-to-date, run git fetch
first.
Just to add my two cents... I wanted to implement this when running jobs in a gitlab pipeline on a gitlab runner. The best way to do this was to use this script:
git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA
Also in my case I wanted to filter files by extension, to achieve this I used:
git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA '*.py'
After that you can for example forward this list somewhere else, a linter perhaps ;)
Hope this will help someone.
To see which files are changed and view the actual code changes compared to the master
branch you could use:
git diff --stat --patch origin master
NOTE: If you happen to use any of the Intellij IDEs then you can right-click your top-level project, select Git > Compare with branch > and pick the origin you want e.g. origin/master
. In the file tree that will appear you can double-click the files to see a visual diff. Unlike the command-line option above you can edit your local versions from the diff window.
Just wanted to add for PyCharm users: You can right-click on the file, -> Git -> Compare with branch
And then you can choose master (or any other)
For a list of files to be pushed, run:
git diff --stat --cached [remote/branch]
example:
git diff --stat --cached origin/master
For the code diff of the files to be pushed, run:
git diff [remote repo/branch]
To see full file paths of the files that will change, run:
git diff --numstat [remote repo/branch]
If you want to see these diffs in a GUI, you will need to configure git for that. See How do I view 'git diff' output with a visual diff program?.
To simply list the commits waiting to be pushed: (this is the one you will remember)
git cherry -v
Show the commit subjects next to the SHA1s.