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?.
Answer from Ionuț G. Stan on Stack OverflowFor 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?.
There is always dry-run:
git push --dry-run
It will do everything except for the actually sending of the data.
If you want a more graphical view you have a bunch of options.
Tig and the gitk script that come with git both display the current branch of your local copy and the branch of the remote or origin.

So any commits you make that are after the origin are the commits that will be pushed.
Open gitk from shell while in the branch you want to push by typing gitk&, then to see the difference between what is on the remote and what you are about to push to the remote, select your local unpushed commit and right-click on the remote and choose "Diff this -> selected":

I'm pretty new to git and I got the basic workflow down. Now I'm trying to improve my skills a bit with git.
Is there some easy way for me to review all of my changes before I push to a remote branch and open a PR?
It would be nice to make sure I didn't forget to remove any unnecessary comments and code. The main thing I could do is simply open the PR and check on Github "files changed" and review it there and do another commit and push if I need to clean things up.
But I'm not sure if there's a way to do this before the PR is even opened. I'm using Android Studio btw so if there's a way in Android Studio (which is basically IntelliJ) then that would be good.
git - How to see changes to a file before commit? - Stack Overflow
How can I see what has changed in a file before committing to git? - Stack Overflow
git - How to view the committed files you have not pushed yet? - Stack Overflow
How to tell the results of git commit before git push? - Stack Overflow
What is git commit?
How to git push command?
How do I check which repo I am in git?
To see all the diff in tracked files but not staged:
git diff
or
git diff path/to/a/given/file
to see the diff only for a file. You can also see the diff in a given sub-directory of your project:
git diff path/to/a/dir/
If you have already staged the changes with git add, you can see what patch you have staged with
git diff --staged
You can also specify a path with --staged.
Make sure you've staged some changes. Otherwise, git commit -v will show you a block similar to what you posted, but not do anything. You can stage changes manually with git add, or if the files are already versioned, you can use git commit -a -v to stage and commit the changes.
For example:
$ echo "more foo" >> foo.txt
$ git commit -v
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: foo.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
Staging the change shows the diff with git commit -v:
:: git add foo.txt
:: GIT_EDITOR=cat git commit -v
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: foo.txt
#
diff --git a/foo.txt b/foo.txt
index 257cc56..a521556 100644
--- a/foo.txt
+++ b/foo.txt
@@ -1 +1,2 @@
foo
+more foo
Aborting commit due to empty commit message.
If you just want to see the diff without committing, use git diff to see unstaged changes, git diff --cached to see changes staged for commit, or git diff HEAD to see both staged and unstaged changes in your working tree.
UPDATE: given your edit, what you really want are the git diff derivatives above. I'm not sure how Aptana Studio works. It may not follow the typical command line git flow. On the command line, you'd stage your changes, and then commit. And the above git diff commands are what you'd use to examine those changes. I typically alias them as git unstaged, git staged, and git both by adding this to my ~/.gitconfig:
[alias]
# show difference between working tree and the index
unstaged = diff
# show difference between the HEAD and the index
staged = diff --cached
# show staged and unstaged changes (what would be committed with "git commit -a")
both = diff HEAD
You're looking for
git diff --staged
Depending on your exact situation, there are three useful ways to use git diff:
- Show differences between index and working tree; that is, changes you haven't staged to commit:
git diff [filename]
- Show differences between current commit and index; that is, what you're about to commit (
--stageddoes exactly the same thing, use what you like):
git diff --cached [filename]
- Show differences between current commit and working tree:
git diff HEAD [filename]
git diff works recursively on directories, and if no paths are given, it shows all changes.
Use git-diff:
git diff -- yourfile
Assuming you're on local branch master, which is tracking origin/master:
git diff --stat origin/master..
Here you'll find your answer:
Using Git how do I find changes between local and remote
For the lazy:
- Use "git log origin..HEAD"
- Use "git fetch" followed by "git log HEAD..origin". You can cherry-pick individual commits using the listed commit ids.
The above assumes, of course, that "origin" is the name of your remote tracking branch (which it is if you've used clone with default options).
If you run git status before git commit it will tell you which changes will be included in the commit and which won't.
Once you've run git commit the changes are already checked in to your local repository. Pushing does not check them in, it just updates another repository with the commits you have in your local repository. This is different from a centralised VCS like Subversion.
Before you push there are several ways of seeing what will be pushed:
git diff origin/masterwill show the differences between your current state andorigin/master.git log origin/master..masterwill list the commits that will be pushed, but not show you their contents.
git show
will show the details of the commit last commit.
If there were more than one commit you can also use
git diff origin/master
assuming your remote is named origin and the branch you want to push to is master.
To see the diff for a particular COMMIT hash, where COMMIT is the hash of the commit:
git diff COMMIT~ COMMIT will show you the difference between that COMMIT's ancestor and the COMMIT. See the man pages for git diff for details about the command and gitrevisions about the ~ notation and its friends.
Alternatively, git show COMMIT will do something very similar. (The commit's data, including its diff - but not for merge commits.) See the git show manpage.
(also git diff COMMIT will show you the difference between that COMMIT and the head.)
As mentioned in "Shorthand for diff of git commit with its parent?", you can also use git diff with:
git diff COMMIT^!
or
git diff-tree -p COMMIT
With git show, you would need (in order to focus on diff alone) to do:
git show --color --pretty=format:%b COMMIT
The COMMIT parameter is a commit-ish:
A commit object or an object that can be recursively dereferenced to a commit object. The following are all commit-ishes: a commit object, a tag object that points to a commit object, a tag object that points to a tag object that points to a commit object, etc.
See gitrevision "SPECIFYING REVISIONS" to reference a commit-ish.
See also "What does tree-ish mean in Git?".
The result of my git message is:
[main 97e3706] pushing directory 2 files changed, 10 insertions(+) To github.com:mementomoriok/files.git 077584e..97e3706 main -> main
Might there be some way to show the actual file names, instead of "2 files changed" ?