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.
git - How to see changes to a file before commit? - Stack Overflow
Is there a way to see how a file looked like at a certain point in time on GitHub?
"View File at Revision" for files in the Commit Details View
How can I see what has changed in a file before committing to git? - Stack Overflow
Videos
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
Like if I wanted to see how a file in a repository looked like on January 12th, 2014? Is there also a way to see how the whole repository looked like on a particular date?
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
You can use git show with a path from the root of the repository (./ or ../ for relative pathing):
$ git show REVISION:path/to/file
Replace REVISION with your actual revision (a Git commit SHA, tag name, branch name, relative commit name, or any other way of identifying a commit in Git).
For example, to view the version of file <repository-root>/src/main.c from 4 commits ago, use:
$ git show HEAD~4:src/main.c
Git for Windows requires forward slashes even in paths relative to the current directory. For more information, check out the man page for git-show.
Doing this by date looks like this if the commit happened within the last 90 days:
git show HEAD@{2013-02-25}:./fileInCurrentDirectory.txt
Note that HEAD@{2013-02-25} means "where HEAD was on 2013-02-25" in this repository (using the reflog), not "the last commit before 2013-02-25 in this branch in history".
This is important! It means that, by default, this method only works for history within the last 90 days. Otherwise, you need to do this:
git show $(git rev-list -1 --before="2013-02-26" HEAD):./fileInCurrentDirectory.txt
I don't want to see the changes, just how the file exists in the commited state. I know I can check out the commit and see it, but is there a way to do so without the checkout? Probably a stupid newbie question, thanks for the help.