Do a “git diff” between two directories due to website owner making live changes

I have a project I’m working on which I’ve set up in a git repo.

Since I put my latest version live, the website owner has made some changes to the working/content by overwriting it directly.

  • Using Visual Studio 2012's built-in merge tool with Git
  • Highlighting added/deleted lines, ignoring moves, in a patch file
  • How to tell `git log --stat` to count empty lines
  • Using mercurial and beyond compare 3(bc3) as the diff tool? help needed
  • How to check real git diff before merging from remote branch?
  • Shortcut for specifying modified files as arguments to git diff
  • Obviously these changes were made outside of version control. I suppose I could overwrite the entire contents of my repo, then commit. That should work… but I don’t really like the idea of doing that, especially if there’s been any replacement of correct code/html-structure with stuff that’s incorrect or bad practice.

    What I’d like to do is dump the website from live into another directory and do a recursive diff so I can only overwrite those files which have changed (any correct any issues if there are any)

  • git rm -r --cached not removing submodule folder and contents
  • Script/Bash: How to add if-statement and check fatal error?
  • push from bitbucket repository to shared hosting ftp server
  • Retaining topic branch commits with git-svn dcommit
  • Why does tracking branch create a new remote branch?
  • git blame throws a bad revision error with the -L <n,m> option
  • 3 Solutions collect form web for “Do a “git diff” between two directories due to website owner making live changes”

    As in if I just overwrite what’s in my git repo, then run git status?

    No, you don’t have to overwrite anything.

    You can do a diff between:

    • the index representing your site in its latest versioned state (in the git repo)
    • a dump of the current live site (a copy done in a different folder, not under version control)

    You can then do (using git options) a:

    git diff --git-dir=/path/to/repo/.git --work-tree=/path/to/dump .
    

    You actually can execute that command from any folder: it will look for the git index and for the right working tree.


    The OP Tom Busby adds in the comments:

    In the end I solved it by simply overwriting the .git folder in my dump directory with the one from my git repo and running git diff.

    VonC’s answer is excellent, but I believe you could also just use the diff command (a built-in command on most operating systems). This would also ensure that “gitignored” files were diffed (though VonC’s might already do that).

    Assuming the website in /www/mysite and a fresh clone in /git/mysite you could just do:

    diff /www/mysite /git/mysite

    Yes We can compare two directories very easily

    simply using this command on Shell/Terminal

    git diffdir any-branch-name any-other-branch-name

    Git Baby is a git and github fan, let's start git clone.