FAQ: How to Backtrack - git checkout

This community-built FAQ covers the “git checkout” exercise from the lesson “How to Backtrack”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn Git

FAQs on the exercise git checkout

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Im having a difficult time trying to figuring out how im using the :
_git diff _ command.

it works until I modify the text of the scene-5.txt Once I change the text and run the git diff I get nothing… any Ideas?


The command - “git checkout HEAD filename” does not discard the changes in the working directory.
can someone explain this?


I had to close and re-open the file before it would show the changes were discarded:

  1. Click the “X” next to scene-5.txt
  2. Click Open File under Code Editor
  3. Select scene-5.txt

Hi. After using the git checkout command, the changes are not show in the working directory. This is despite using the process outlined by tensor2. Any suggestions?

Close and re-open the file to show the changes.

Is there any reason the lesson is having us specify HEAD with the checkout command? Can’t it be omitted since the HEAD is targeted by default?