diff against the working directory with git-latexdiff

1,950

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?

Share:
1,950

Related videos on Youtube

user2740
Author by

user2740

Updated on September 17, 2020

Comments

  • user2740
    user2740 about 3 years

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

    \documentclass{article}
    \begin{document}
      a
    \end{document}
    

    add git-latexdiff to $PATH in .bashrc

    PATH=$PATH:~/path/to/dir/git-latexdiff/
    

    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.
    /usr/bin/latexpand
    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
    

    version:

    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)

  • user2740
    user2740 over 8 years
    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.
  • Matthieu Moy
    Matthieu Moy over 8 years
    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.
  • user2740
    user2740 over 8 years
    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
  • Matthieu Moy
    Matthieu Moy over 8 years
    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.
  • user2740
    user2740 over 8 years
    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.