How to see changes to a file before commit?
git
Solution
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
Problem
I have tried `git commit -v` ``` ubuntu@ip:~/agile$ 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: .htaccess # no changes added to commit (use "git add" and/or "git commit -a") ubuntu@ip:~/agile$ ``` But it is just showing me that `.htaccess` has changed, but not what has changed. How do I achieve this? Update: In Aptana Studio it is possible to see the changes before you commit anything. So back to my question, there must be a way to see the difference to the original state, before you actually commit. Maybe there is a different command for that.