git diff target_branch..current_branch Where current_branch is the branch you will open the PR from (or HEAD) and target_branch is the branch you want to merge into. Note that since this is just regular git diff all the same format options or path arguments can also be applied. https://git-scm.com/docs/git-diff Answer from Deleted User on reddit.com
🌐
Reddit
reddit.com › r/git › can i see all of my changes before i push them and open a pr?
r/git on Reddit: Can I see all of my changes before I push them and open a PR?
June 11, 2021 -

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.

Top answer
1 of 2
76

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.

2 of 2
35

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
Discussions

How to see changes in git commits, before pushing them | Drupal.org
I have a module in drupal.org git. My local copy has 2 commits pending, but I was expecting to see only one. So, I'm curious what's in the other commit that I either forgot to push or who knows what happened. So, here's what git tells me... [dave@starbuck fb-3]$ git status # On branch 6.x-3.x ... More on drupal.org
🌐 drupal.org
June 1, 2011
how does git know what change you're commiting?
Because the git tradition of staging a file via git add before committing selected files has its reason, as when working on a large codebase, it's very common to see many files with very similar names, going directly to git commit filename without the git add step may easily committing a wrong ... More on teamtreehouse.com
🌐 teamtreehouse.com
3
November 12, 2015
linux - How to get the modified files(before and after) from git version server? - Unix & Linux Stack Exchange
If you want to compare what's different, git show already shows the differences. Why do you need the files? ... @ muru I need to get the midified files(before & after) then compare them, and merge them to another code branch, so I need the modified(before & after) files. ... However, it’s hardly ever necessary to look at details of a change in this way. In your case, to apply a commit ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
January 31, 2018
Can I see all of my changes before I push them and open a PR?
git diff target_branch..current_branch Where current_branch is the branch you will open the PR from (or HEAD) and target_branch is the branch you want to merge into. Note that since this is just regular git diff all the same format options or path arguments can also be applied. https://git-scm.com/docs/git-diff More on reddit.com
🌐 r/git
15
6
June 11, 2021
🌐
Tom de Bruijn
tomdebruijn.com › posts › git-review-changes-before-committing
Git: Review changes before committing | Tom de Bruijn
October 26, 2020 - Git commits can be made very quickly, but we don't see what changes are committed. We can improve the way we make commits by reviewing what we commit first.
🌐
Git
git-scm.com › book › en › v2 › Git-Basics-Recording-Changes-to-the-Repository
Git - Recording Changes to the Repository
Adding the -a option to the git commit command makes Git automatically stage every file that is already tracked before doing the commit, letting you skip the git add part: $ git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git ...
🌐
Graphite
graphite.com › guides › git-view-changes
How to view changes in Git
For Graphite documentation, see our CLI docs. This guide will explore the different methods to view changes in Git, using commands like git diff, git status, and others. Before explaining the specific commands, it’s essential to understand ...
🌐
Drupal
drupal.org › forum › support › module-development-and-code-questions › 2011-06-01 › how-to-see-changes-in-git-commits
How to see changes in git commits, before pushing them | Drupal.org
June 1, 2011 - You changed it again and committed. if you do a diff, you see the difference between what was in the origin repo, and what your version is now - effectively one line changed. What happened, because git tracks local commits as events, and will forward each event up into the commit log - is there were two commits that happened.
Find elsewhere
🌐
LabEx
labex.io › questions › how-to-view-changes-before-committing-387457
How to View Changes Before Committing in Git | LabEx
September 19, 2024 - Now, you can use git status to check the current state of your repository: $ git status On branch main Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: index.html no changes added to commit (use "git add" and/or "git commit -a...
🌐
Opensource.com
opensource.com › article › 21 › 4 › git-whatchanged
Find what changed in a Git commit | Opensource.com
Not only can you see which files changed, but you can also make git log display exactly what changed in the files. Your Git log can produce an inline diff, a line-by-line display of all changes for each file, with the --patch option: commit ...
🌐
Git
git-scm.com › book › en › v2 › Git-Basics-Viewing-the-Commit-History
Git - Viewing the Commit History
For example, if you want to see which commits modifying test files in the Git source code history were committed by Junio Hamano in the month of October 2008 and are not merge commits, you can run something like this: $ git log --pretty="%h - %s" --author='Junio C Hamano' --since="2008-10-01" ...
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-see-the-changes-in-a-git-commit
Inspecting Changes in a Git Commit - GeeksforGeeks
January 19, 2026 - Run git show <commit-hash> to view the details of a specific commit. ... After committing changes, run git log to list commits and select a specific one to review its changes.
🌐
Scott Willsey
scottwillsey.com › gitcommitdiffs
Git Diff With Previous Commit Versions
June 13, 2023 - The answer is using git diff with not only a filename for the file to compare, but with commit IDs of the two commits in question. It looks like this: ... git diff 5298935609b106365c2786a711c844395539a43d cfcbb396fb29e1e100908152f002ae2f9f6d3f29 package.json · And if you use a difftool for ...
🌐
Git
git-scm.com › docs › git-diff
Git - git-diff Documentation
This is to view the changes between two arbitrary <commit>. If --merge-base is given, use the merge base of the two commits for the "before" side.
🌐
Codemia
codemia.io › knowledge-hub › path › how_to_see_changes_to_a_file_before_commit
How to see changes to a file before commit?
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
freeCodeCamp
freecodecamp.org › news › git-diff-command
Git diff Command – How to Compare Changes in Your Code
March 29, 2022 - Then use git status, which shows which changes are ready to commit like below: Then, let's say I want to make some changes to the dog's name – like I wish to call it "pup" instead of "puppy".
Top answer
1 of 3
1
Hi @Brandon Lind (https://teamtreehouse.com/brandonlind2) you can run linux git status this comment shows you what files have been changed since the last commit, and what files will be committed if you run git commit. Remember, git makes absolutely no assumption on what to commit, it only commit whatever it was told to commit. And to do so you need to manually add the changed files to the tracking stage by using git add filename before running the git commit; in another word, those changed files that haven't been added to the tracking stage won't get committed.
2 of 3
0
Hi Brandon, I'd recommend that you go and have a quick read of the git add (https://git-scm.com/docs/git-add) and the git commit (https://git-scm.com/docs/git-commit) commands documentation. As documentation goes it's quite approachable. Basically you use the 'git add' commands to make sure that git is aware of the changes that you have been making to files. Then you use the 'git commit' commands to well ... commit those changed files to your repository. "git add can be performed multiple times before a commit. It only adds the content of the specified file(s) at the time the add command is run; if you want subsequent changes included in the next commit, then you must run git add again to add the new content". So I believe that if you make a change to a file, use git add to stage that file ready for your commit but then make further changes to the file then you will need to run a git add against the file again otherwise it will only commit the changes from the last add. Maybe Running 'git commit' will commit all of the file snapshots that are currently staged using the 'git add' commands. But you can selectively commit files by using the file name as an argument to the commit command ... but I'm not sure if that will use the latest version of that file that you staged or if it will just take the file directly including any updates that you had not staged using an add. Hmm ... I think the best think to do is to set yourself up a git repository and have a play. Have a look at the docs and try a few things out. So as Steve has already said "I hope that helps - I'm not sure it did!" :-) "how does git know what change you're commiting?" - The direct answer would be that if you are not specifying a filename as part of the commit command, then it will commit all of the changes that you have previously staged using the git add commands since your last full commit. You can use the git status command to get the listing of the files that are currently staged and will be committed.
🌐
Refine
refine.dev › home › blog › engineering › git diff - comparing changes in git
git diff - Comparing Changes in Git | Refine
July 30, 2024 - If you want to find the differences ... the differences between the two commits. ... We previously delved into how we can use 'git diff' with Git hashes to compare two specific commits....
🌐
GitHub
docs.github.com › articles › differences-between-commit-views
Differences between commit views - GitHub Docs
When Git shows the history of a single file, it simplifies history by omitting commits that did not change the file. Instead of looking at every commit to decide whether it touched the file, Git will omit a whole branch if that branch, when merged, did not impact the final contents of the file.
🌐
Git
git-scm.com › docs › git-commit
Git - git-commit Documentation
by using the -a switch with the commit command to automatically "add" changes from all known files (i.e. all files that are already listed in the index) and to automatically "rm" files in the index that have been removed from the working tree, and then perform the actual commit; by using the --interactive or --patch switches with the commit command to decide one by one which files or hunks should be part of the commit in addition to contents in the index, before finalizing the operation. See the “Interactive Mode” section of git-add[1] to learn how to operate these modes.
🌐
DEV Community
dev.to › hadil › the-15-git-commands-every-software-engineer-uses-and-why-they-matter-more-than-you-think-c51
The 15 Git Commands Every Software Engineer Uses (And Why They Matter More Than You Think) - DEV Community
January 20, 2026 - git pull fetches changes from a remote repository and integrates them into your current branch (by merge or rebase, depending on configuration) Common mistake: Pulling into a dirty working directory instead of committing or stashing first. git ...
Top answer
1 of 2
2

To see the state of files before and after a given commit, check out its parent:

git checkout 41f9f4e3~1

then the commit itself:

git checkout 41f9f4e3

However, it’s hardly ever necessary to look at details of a change in this way. In your case, to apply a commit to another branch, cherry pick it:

git checkout ${target_branch}
git cherry-pick -x 41f9f4e3

(replacing ${target_branch} as appropriate). The -x option adds a comment in the commit message with the origin of the cherry-pick.

2 of 2
1

Thanks all, I have found the correct way, here it is.

#!/bin/bash
from_id=$1
to_id=$2
#echo $from_id
#echo $to_id
diffpath='patch/diff.log'
newpath='patch/new/'
oldpath='patch/old/'
rm -rf patch
mkdir -p $newpath
mkdir -p $oldpath
git diff $from_id $to_id --raw > $diffpath
cat $diffpath | while  read line
do 
    #echo =====================================
    #echo $line
    OLD_IFS="$IFS"
    IFS=" "
    arr=($line)
    IFS="$OLD_IFS"   
    #echo ${arr[4]}
    filepath=${arr[4]##* }
    #echo $filepath
    newid=${arr[2]%%...}
    #echo $newid
    oldid=${arr[3]%%...}
    #echo $oldid  

   if [ "$newid"x != "0000000"x  ]; then   
     newfilepath=${newpath}${filepath}
     echo $newfilepath
     dirpath=${newfilepath%/*}
     echo $dirpath
     mkdir -p ${dirpath}
     git cat-file -p $newid >  ${newfilepath}
   fi

   if [ "$oldid"x != "0000000"x  ]; then 
     oldfilepath=${oldpath}${filepath} 
     echo $oldfilepath
     dirpath=${oldfilepath%/*}
     echo $dirpath   
     mkdir -p ${dirpath}
     git cat-file -p $oldid >  ${oldfilepath}
   fi   
done 

You will found the new directory named patch in current working directory after doing this.