1

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?

rhodee
  • 1,257
  • 1
  • 14
  • 27

2 Answers2

3

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.

twalberg
  • 59,951
  • 11
  • 89
  • 84
  • I ran the `git ls-remote origin master` command. Are the values saved to the FS (e.g. .git/). The reason I ask is I would like to periodically check this value and if it changes, do something. – rhodee Feb 27 '13 at 19:15
  • No, they don't automatically get saved (`git fetch` would save them, but also retrieve everything). There's nothing preventing you from saving the output away somewhere, though... – twalberg Feb 27 '13 at 19:54
  • That is exactly what I landed up doing. the gist of my script is to check for changes in SHA1 via the ls-remote, then I need to determine how to update the git log. marking this as answered. – rhodee Feb 27 '13 at 20:09
1

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.

David Culp
  • 5,354
  • 3
  • 24
  • 32