Comparing files

as far as I understand it (please correct me if I’m wrong), to use Git inside RStudio you must:

  1. create a local repository, at least (I don’t think a remote repository is needed too)
  2. you can only compare files having the same name, i.e., two different commits of the same repo, but not two text files with different names

Actually, neither of those is true if you use the command-line git.

  1. If you have Git installed, you can use its diff functionality on files that aren't part of any repository - just use the --no-index option. I do this fairly frequently, just because I like the colorized (and sometimes word-level) output, and because I have git diff configured to use a pager without explicitly piping to less or similar.

  2. When using --no-index, you can diff two files just by listing both filenames on the command line.

So I'd recommend:

git diff --no-index file1.Rmd file2.Rmd

-- the only disadvantage of which is that you have to leave the Rstudio graphical environment.

2 Likes