tags:

views:

162

answers:

2

Hi,

I'm using a local Git project repository, and have created a remote repository followed by pushing the contents of my local repository to the remote repository using the git push origin master command. I can now perform commits and other tasks just fine.

What I'm trying to do now is retrieve the latest commit log message for a specific file from the command-line on the remote server. On the local server I can retrieve this information by executing:

git log -1 --format="%cr %s"  test.docbook

However how can I perform the same on the remote server? Executing the above command from within the remote repository always returns:

fatal: ambiguous argument 'test.docbook': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

Surely there's some way to accomplish this?

Thanks! Jason

+3  A: 

Do what git tells you to do! Separate the paths from the revisions using --:

git log -1 --format="%cr %s" -- test.docbook
innaM
+3  A: 

I assume your remote repository is a bare repository? In order to make sense of the arguments to commands like "git log", git needs to decide if each argument is naming a revision or a file. Usually this is done using a heuristic- if the argument matches a file that exists, then it's a filename, otherwise try interpreting as a path.

The problem is, with a bare repository, the file "test.docbook" doesn't exist on the filesystem so git can't tell if you mean the commit identified as "test.docbook" or HEAD limited to the path "test.docbook". You can solve the ambiguity by adding a "--" to the argument list- this forces git to interpret arguments before "--" as commits and those after "--" as paths.

So in summary, try:

git log -1 --format="%cr %s" -- test.docbook

Since there are no revision arguments, git will assume "HEAD" as usual.

araqnid
Manni and araqnid YOU ARE THE BEST!!! Thanks so much, this was driving me crazy.
Jason