I use git for my latex document and I want to diff against the working directory.


add git-latexdiff to $PATH in .bashrc


setup git:

git init; git add .; git commit -m "initial commit"

change content of file from a to aa

git add file.tex; git commit -m "2nd commit"

change content of file from aa to aaa

(use git log to see hashes for commits)

git-latexdiff -v --main file.tex hash1 hash2

(-v is verbose, --main specifies the main file, hashes identify commits)
works just fine.

But when I try to commit against the uncommitted working directory:

user2740$ git-latexdiff -v --main file.tex hash1 --
Auto-detecting PDF viewer ... xdg-open.
Creating temporary directories ... done.
Temporary directories: /tmp/git-latexdiff.3840/old and /tmp/git-latexdiff.3840/new
Checking out old and new version ...ln: failed to create symbolic link ‘./file.tex’: File exists


user2740$ git-latexdiff --version
1.0                                  #downloaded 09.05.2014

Works Now:

Make sure to use the latest version!

Execute only in your desired directory even for version information. (at least for version v1.1.2-1-ga985a4f)

2 Answers 2


Do not ever use "sudo" for any task that creates file in your home directory. "sudo" does not only gives you permissions to do more things, it also executes the command as a different user, so you will end up with files belonging to root on your account. This is not only useless, but actually harmful. Use sudo for administrative tasks (e.g. upgrade you LaTeX install), but not for daily work.

The command git-latexdiff -v --main file.tex hash1 -- just works for me. git-latexdiff does a temporary checkout in a directory with a unique name under /tmp/. Are you using the latest version of git-latexdiff?

  • For some reason I used to access git-latexdiff via a symlink in /usr/local/bin, yielding a 'Permission denied' unless using sudo. Adding it in .bashrc solves that problem. I updated the question to the latest version of git-latexdiff.
    – user2740
    May 9, 2015 at 14:10
  • 1
    There have been several fixes related to your problem since then. Please, upgrade to v1.1.1 that I just pushed and let me know if the problem persists or disappears. May 10, 2015 at 14:48
  • now i get: fatal: Not a git repository (or any of the parent directories): .git when calling git-latexdiff. calling it in its own directory works however
    – user2740
    May 10, 2015 at 16:54
  • There was a bug in git latexdiff --version if you installed it other than by git clone-ing the repo. But you anyway need to run git latexdiff from a Git directory, that's the point of the tool. May 10, 2015 at 17:29
  • My bad. I was testing git-latexdiff --version in an arbitrary directory because I just wanted to see whether the right version was in the $PATH. I then thought the error message was referring to the git-latexdiff-repo as the value for version is now extracted from there. My MWE works now! Thank you so much for your continued efforts.
    – user2740
    May 10, 2015 at 20:05

Try running the git latexdiff command in the root of the Git repository. It worked fine for me this way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.