Reputation: 7802
Given that Git is very SHA-1 friendly, I would surmise that it is possible to easily check for this scenario:
-I have a repo with a directory foo/ somewhere within it. -Someone on some other computer makes a change to foo's contents (including nested subdirectories), and pushes the change to the repo.
My guess is that I will have to do a fetch and check if there is some difference between the SHA-1 for my directory and the SHA-1 of the remote directory, but I don't know how to do this.
Upvotes: 2
Views: 757
Reputation: 265807
you can simply use git diff --quiet
and check its exit code:
git fetch # get latest code from upstream
git diff --quiet master..origin/master -- foo/ || echo 'directory differ'
diff --quiet
will exit with 1 when there are differences and exit with an error code of 0 the objects (blob or tree) are identical
Upvotes: 6