Klaus S.
Klaus S.

Reputation: 1219

Finding out that a git repository has changed

I'm looking for a pragmatic way of finding out if a git repository has changed in any way (new commits, new branch, etc.). The purpose of finding an answer to this question is to create a simple caching system in web repository viewer, with proper invalidation.

See: https://github.com/klaussilveira/gitlist/issues/260 for more info. Thanks in advance, guys.

Upvotes: 1

Views: 81

Answers (2)

CharlesB
CharlesB

Reputation: 90496

My naive approach would be to store and compare the output of git show-ref. If a branch is updated, then the corresponding head will be at different SHA at next show-ref, and if a branch is added it will appear as a new entry. Idem for tags.

It's a cheap command so it should scale OK on your 20k repos.

Upvotes: 2

asm
asm

Reputation: 8898

What about git remote show <remote-name>? You get output for each branch like this:

  Remote branch:
  master tracked
   Local branch configured for 'git pull':
   master merges with remote master
   Local ref configured for 'git push':
   master pushes to master (local out of date)

Upvotes: 1

Related Questions