rhodee
rhodee

Reputation: 1267

Detecting changes to remote branch

I currently am observing for changes in .git/refs/remotes/origin/master

My objective is to detect a change SHA on the remote, presumably because someone has made a commit. In order to pull down the lastest remote details I run git fetch --quiet --update-head-ok remoteName. This does not appear to be the correct file being updated with that command.

Which dir/file should be observed?

Upvotes: 1

Views: 1331

Answers (2)

twalberg
twalberg

Reputation: 62489

Don't monitor files in the inner workings of git manually. Use git to check things for you. In this case git rev-parse --verify origin/master will show you the SHA of your local copy of origin/master, and git ls-remote origin master to get the SHA from the remote.

I suspect you're running into the case that the file .git/refs/remotes/origin/master may be out of date, because many infrequently-changed refs are no longer actually stored in individual files, but in .git/packed_refs. If both exist, git knows which one to trust.

Upvotes: 3

David Culp
David Culp

Reputation: 5480

That is the file that will contain the new commit hash if the master branch on remote origin has been updated. Different remotes and different branches will have the expected respective folder/file location.

To see exactly where the changes are being recorded, run the fetch command without the --quit argument. The last line(s) of the response (if there was anything to fetch) will tell you where the downloaded change was recorded.

For instance, this page on 'GIT HowTo' give the example

$ git fetch
From /Users/marina/Documents/Presentations/githowto/auto/hello
   6e6c76a..2faa4ea  master     -> origin/master

The last line says the record of changes on the remotes master branch were recorded at origin/master -- or more specifically, .git/refs/remotes/origin/master.

Upvotes: 1

Related Questions