0

I'm new in git and ruby on rails, i'm trying to recover an other day work with git, so I type "git log" and i can see my "commits" for the repository in my application directory:

commit 016a8807427c46087762b56e1ea02abc
Author: Antonio 
Date:   Mon Feb 4 11:32:32 2013 +0100

    session errors

commit cc3c292ffd110414cf4db54c5b976f2f
Author: Antonio 
Date:   Sun Feb 3 21:02:59 2013 +0100

    hw2_c

commit af2a509d462e454d0315c63ce98ad6d0
Author: Antonio 
Date:   Sun Feb 3 20:34:55 2013 +0100

    hw2_elementsId

commit 2314687a32c7f56ff8fc8557d95af3df
Author: Antonio 
Date:   Sun Feb 3 20:25:23 2013 +0100

    hw2_b

But when i try to checkout any commit, I receive always the same error message:

git checkout hw2_c

error: pathspec 'hw2_c' did not match any file(s) known to git.

Can anyone help me?

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
Lorraine
  • 441
  • 5
  • 23

1 Answers1

1

You can't check out a commit by its message. You need to check out using the hash:

git checkout cc3c292ffd110414cf4db54c5b976f2f

If you want a symbolic name, make a branch or tag at that hash:

git branch hw2_c cc3c292ffd110414cf4db54c5b976f2f
git tag hw2_c cc3c292ffd110414cf4db54c5b976f2f
Carl Norum
  • 219,201
  • 40
  • 422
  • 469
  • Thank very much, it work perfectly, then, when I do a commit with: `git commit -m "hw2_c"` the hw2_c is only a comentary about that commit? – Lorraine Feb 06 '13 at 18:36
  • Yes, that's right. The commit is identified by its hash, which takes into account the tree state, commit message, comitter name & email, and time/date of the commit. – Carl Norum Feb 06 '13 at 18:38