gitdiffrevisionmagit

How can I diff a file with a specific revision in Git?


I don't know if Git has the concept of a revision.

I'd like to diff the current working copy with an older version of it (not necessarily the last commit).

It would be great if it could be done inside Emacs.


Solution

  • I've no idea about doing this inside Emacs, but:

    git diff rev1..rev2
    

    will do what you want for the whole repository. You can then add to that:

     git diff rev1>..rev2 path
    

    path can be an absolute path to a file, or a path to a directory, so you can diff subtrees.

    If you're looking to diff the working copy - just specify revision 1:

    git diff rev1 path
    

    The revision codes can be special names, for example, HEAD^..HEAD means last to current, or their SHA-1 values from the logs.