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

Question 'git checkout' - Git

On the video "Looking back on what we have done" I followed the steps using 'git log' 'git checkout 309c5'

however when I did that my file1, file2, and file3 all disappeared unlike on the video.

'ls' brought me solely README

309c5 was a commit to change the README file. It had nothing to do with file1 - 3.

When I do 'git master' they all come back

What is going on?

I am on OS X

1 Answer

Hi Jake,

When you do a git checkout, it's kind of like taking a new book down from the shelf. Your other books are still there, but you can't see the contents - you can only read the one currently in your hand. When you checked out commit XXXX, you have access to the files it contains, but not to master. When you switched back to master (checkout master) you put away the book called commit XXXX and grabbed another (master) instead. Hope that lame analogy helps clarify. :)

You can read more about branching and checkouts in the Git book.

Best, Cena

Im curious though, in the video, even before switching back to master, ls had file1 - file3 show up?