Information
Changes and Differences
- git status
-
Show files added to the index, files with changes, and untracked files.
- git diff
-
Show unstaged changes made since your last commit.
- git diff --cached
-
Show changes staged for commit (i.e., difference between index and last commit).
- git diff HEAD
-
Show changes (staged and unstaged) in working directory since last commit.
- git diff rev [path(s)]
-
Show differences between working directory and revision rev, optionally limiting comparison to files found in one or more space-separated file paths or subdirectories given by path(s).
- git diff rev1..rev2 [path(s)]
-
Show differences between two revisions, rev1 and rev2, optionally limiting comparison to files found in one or more space-separated file paths or subdirectories given by path(s).
- git diff rev1...rev2 [path(s)]
-
Show differences between the last common ancestor of two revisions, rev1 and rev2, optionally limiting comparison to files found in one or more space-separated file paths or subdirectories given by path(s).
- git fetch remote; git diff ..remote
-
Update changes in remote branch remote (defaults to "
origin
"), and show differences from current HEAD.
File and Directory Contents
- git show rev:file
-
Show contents of file (specified relative to the project root) from revision rev.
- git ls-files [-t]
-
Show all tracked files ("-t" shows file status).
- git ls-files --others
-
Show all untracked files.
Commit History
- git log
-
Show recent commits, most recent on top.
- git log [path(s)]
-
Show recent commits, most recent on top, limited to the file or files found on path(s) if given.
- git log -p
-
Show recent commits, most recent on top, with full diffs.
- git log -p [path(s)]
-
Show recent commits, most recent on top, with full diffs, limited to files found in one or more space-separated file paths or subdirectories given by path(s).
- git log -g
- Show recent commits, most recent on top, walking the full reflog entries instead of the commit ancestry chain up to the current HEAD. By default, "git log"
reports all commits only up to the current HEAD, even if HEAD has descendents on the current branch (as, for example,
might happen if you ran "git reset rev" to move HEAD to a previous point in history).
The "-g" option will report the full history.
- git log --stat [path(s)]
-
Show recent commits, with stats (files changed, insertions, and deletions), optionally limited to files found in one or more space-separated file paths or subdirectories given by path(s).
- git log --author=author
-
Show recent commits, only by author.
- git log --after="MMM DD YYYY"
-
Show commits that occur after a certain date, e.g. "Jun 20 2008".
- git log --before="MMM DD YYYY"
-
Show commits that occur before a certain date.
- git whatchanged file
-
Show only the commits which affected file listing the most recent first.
- git blame file
-
Show who authored each line in file.
- git blame file rev
-
Show who authored each line in file as of rev (allows blame to go back in time).
- git rev-list --all
-
List all commits.
- git rev-list rev1..rev2
-
List all commits between rev1 and rev2.
- git show rev
-
Show the changeset (diff) of a commit specified by rev.
- git show rev -- path(s)
-
Show the changeset (diff) of a commit rev , optionally limited to files found in one or more space-separated file paths or subdirectories given by path(s).
- git for-each-ref
-
List all commits pointed to by tags and branch HEAD's.
- git fetch remote; git log ..remote
-
Update changes in remote branch remote (defaults to "
origin
"), and show new commits in not in current HEAD.