Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools

Dan Williams
Dan Williams
5,339 Points

Git Basics Getting Started With Git An Old-Fashioned Git-Together stuck on code challenge

I'm following the Git Basics Getting Started With Git deep dive.

I'm stuck on the the 9th challenge which is named

HEAD~1 is a special commit identifier in git; it stands for the previous commit (not the one we just made, but the one before that). Can you use that identifier to check out the previous commit in this repository?

Any guides or help where to start with this, kind stuck....

8 Answers

Dan Williams
Dan Williams
5,339 Points

Can you tell me where in the videos this was covered and I will review?

git checkout HEAD~1

Robbie Thomas
Robbie Thomas
31,093 Points

I tried git checkout HEAD and not HEAD~1. They let me pass!

Dan Williams
Dan Williams
5,339 Points

Aha, sorted it, thanks for the support! ;-)

Mário Ribeiro
Mário Ribeiro
10,439 Points

Hello Tommy,

I'm having problems with the ~ symbol. I'm unable to use it.. already tried copy / paste without success. Restarted the challenge over 20 times :)

Thank you.

Mário Ribeiro
Mário Ribeiro
10,439 Points

Now solved. Tried a couple of times again, and worked..

Iván Murillo
Iván Murillo
11,912 Points

Hey Mário! I'm having problems too with the ~ symbol. How did you solved it?

EDIT: The ~ symbol doesn't work in the treehouse's console if you are using a non-american keyboard. Solved with a copy and paste!

Dave Huish
Dave Huish
17,727 Points

The confusion for me was the words "check out". I thought initially I had to look add the log. Instead, it is literally asking you to access the files using Git's checkout.

git checkout HEAD~1 is what I ended up with.

I was making it far too complicated for myself.

Tommy Morgan
STAFF
Tommy Morgan
Treehouse Guest Teacher

Hey Dan Williams -

Have you tried anything at all here yet, or are you not sure what to try? I'd be glad to give you some hints :)

Dan Williams
Dan Williams
5,339 Points

Hi Tommy, I've tried multiple things...but I'm not sure If I'm barking up the wrong tree!

I thought git reset HEAD -- index.hmtl but have had no luck..

Tommy Morgan
Tommy Morgan
Treehouse Guest Teacher

Well, there's a bit of a clue in the question:

...Can you use that identifier to check out the previous commit in this repository?

This question is asking you to switch to a different version of the code in your repository. There's a command we covered for doing just that :)

Also, remember that commit identifiers in Git are typically mangled-looking strings that are guaranteed to be unique, like 1a8bc38cd3942fea83f4b2dc3251. In this case, though, we're making use of a "special" commit identifier - it's not a hash string like normal, but it's a special keyword that Git knows always means "the second most recent commit."