Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree when using git diff

I am trying to take out git diff of a particular file in a folder using below command on azure devops pipeline:

git diff --name-only HEAD^ .\dev-artifacts.properties .\dev-artifacts.properties

or

git diff --name-status HEAD HEAD^

or

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

git diff --name-only dev-artifacts.properties dev-artifacts.properties

After running this command, I am getting below error:

fatal: ambiguous argument ‘HEAD^’: unknown revision or path not in the
working tree. Use ‘–‘ to separate paths from revisions, like this:
‘git […] — […]’

I tried switching the branch (main branch), but still it is not working. But in my local I am able to get the difference using git diff.

I want to get the difference using git diff, so that I can run a python script when there is a change in file.

>Solution :

You have a shallow repository with only a single commit. You can verify by executing git rev-parse --is-shallow-repository.

HEAD^ points to the commit before your current commit – which does not exist in shallow clones of depth 1. You have to unshallow your clone or deepen it to include the commits which you are referencing.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading