[git] How to view file history in Git?

With Subversion I could use TortoiseSVN to view the history/log of a file.

How can I do this with Git?

Just looking for history record for a particular file, and then the ability to compare the different versions.

This question is related to git timeline git-diff git-log revision-history

The answer is


Of course, if you want something as close to TortoiseSVN as possible, you could just use TortoiseGit.


TortoiseGit also provides a command line tool to do see the history of a file. Using PowerShell:

C:\Program` Files\TortoiseGit\bin\TortoiseGitProc.exe /command:log /path:"c:\path\to\your\file.txt"

git log --all -- path/to/file should work


I like to use gitk name_of_file

This shows a nice list of the changes that happened to a file at each commit, instead of showing the changes to all the files. Makes it easier to track down something that happened.


Many Git history browsers, including git log (and 'git log --graph'), gitk (in Tcl/Tk, part of Git), QGit (in Qt), tig (text mode interface to git, using ncurses), Giggle (in GTK+), TortoiseGit and git-cheetah support path limiting (e.g. gitk path/to/file).


My favorite is git log -p <filename>, which will give you a history of all the commits of the given file as well as the diffs for each commit.



you could also use tig for a nice, ncurses-based git repository browser. To view history of a file:

tig path/to/file

Looks like you want git diff and/or git log. Also check out gitk

gitk path/to/file
git diff path/to/file
git log path/to/file

Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to timeline

Responsive timeline UI with Bootstrap3 How do I create a timeline chart which shows multiple events? Eg. Metallica Band members timeline on wiki How to view file history in Git? How to create a timeline with LaTeX?

Examples related to git-diff

How to show uncommitted changes in Git and some Git diffs in detail Git list of staged files Create patch or diff file from git repository and apply it to another different git repository There isn't anything to compare. Nothing to compare, branches are entirely different commit histories git: diff between file in local repo and origin Git diff between current branch and master but not including unmerged master commits How to Diff between local uncommitted changes and origin How to see the changes in a Git commit? How do you take a git diff file, and apply it to a local branch that is a copy of the same repository? git diff file against its last change

Examples related to git-log

How to get commit history for just one branch? How do I see the commit differences between branches in git? Commit history on remote repository How to exit git log or git diff How to search a Git repository by commit message? Get a list of all git commits, including the 'lost' ones How do I run git log to see changes only for a specific branch? How can I view a git log of just one user's commits? Viewing unpushed Git commits How to view file history in Git?

Examples related to revision-history

Go to particular revision What is the Git equivalent for revision number? How to view file history in Git? Unable to show a Git tree in terminal