Git: compare differences across two repositories

Viewed 100

We have a template repo that we clone to create our site repos. When we upgrade sites, we just pull in the template repo into our site repo.

I'm trying to compare what's changed in the site repo at the commit that the last template repo was merged in. There may have been new commits made to the template repo that haven't been merged in yet so I don't want to include those in the comparison.

I can compare differences between the two repos using

git diff template/master master

But this compares against the most recent commit in the template repo. Is there a way to compare it at a certain commit?

Something like

git diff template/master@e9d5dd968 master
1 Answers

Looking at the git-diff(1) man page, the syntax you're using here is:

   git diff [<options>] [--merge-base] <commit> <commit> [--] [<path>...]
       This is to view the changes between two arbitrary <commit>.

In this case <commit> means "anything that refers to a commit", which includes:

  • branch names
  • tag names
  • commit ids
  • relative references (like HEAD^)
  • etc.

In other words, you can run git diff <commit id> <branch name>. So if e9d5dd968 is a commit id, which seems likely, just run git diff e9d5dd968 master.

Related