Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"unknown revision or path not in the working tree" when trying to fetch specific commit to new directory

Total git newbie here,

I wanted to create a new folder that holds a specific commit I made. These are the steps I've taken:

git init
git add remote origin <ssh-clone-url>
git fetch origin <sha1>
git reset --hard HEAD

which gives me this error:

fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.

What am I doing wrong here?

like image 749
user2893128 Avatar asked May 14 '14 01:05

user2893128


1 Answers

Your syntax for adding a remote is backwards.

...
git remote add origin <ssh-clone-url>
...

I think that the better way to do what you want to do is to pull down your master branch and cherry-pick which commit you want.

git remote add origin <ssh-clone-url>
git fetch origin master
git cherry-pick <sha1>

Remember that with git, you always have a full copy of your project history. If you really wanted to ONLY have that specific revision (I don't know why you would want this, but this seems to be what you are asking), simply execute the above command sequence and take the files that you want, getting rid of the detritus.

like image 193
wickstopher Avatar answered Nov 01 '22 23:11

wickstopher