Search code examples
gitgit-diff

Getting the difference between two repositories at specified commits


I am trying to compare the difference between two repositories at given commits. The closest StackOverflow post that I've come across suggests adding one repo as a remote to compare with the working repo with below commands:

git remote add -f b path/to/repo_b.git
git remote update
git diff master remotes/b/master
git remote rm b

However, if I want to compare with the point at a specific past commit of the repo_b (and not just a branch), how can I do that?


Solution

  • Just use the commit hashes instead of the branch names in git diff. For example:

    git remote add -f b path/to/repo_b.git
    git remote update
    git diff 547cd49 600cd49
    git remote rm b
    

    Commit hashes are unique over branches (and universe)