FAQ: How to Backtrack - git reset I

This community-built FAQ covers the “git reset I” 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 reset I

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!

What’s the difference between
git reset HEAD filename
and
git reset filename?

2 Likes

I don’t know how to make a commit to save the Larry/Laertes name swap in hamlet from the terminal can someone help me. its the 5th intruction from HOW TO BACKTRACK

2 Likes

git commit -m “Add LEARTES”

5 Likes

i was stuck there also lol

In this exercise we make changes to scene-2.txt, add it to the staging area, and then unstage the file. We subsequently commit other changes.

But after the commit, I closed scene-2.txt and reopened it, and found that the changes were still present in that file.

If scene-2.txt had never been committed, how would one go about recovering the changed content in that file? In the exercise I only changed a line, but imagine that many parts had been changed in different parts of the file. Perhaps the solution is to do an initial commit to be able to restore a previous version?

I was thinking the same think as “doctorplatano”.
What happens if “scene-2.txt” has never previously been committed? How can it be “reset” from HEAD if there is nothing in HEAD?

What does it mean?

What if, before you commit, you accidentally delete an important line from scene-2.txt? Unthinkingly, you add scene-2.txt to the staging area.

I thought you need to explicitly execute git add to get any changes to the staging area. But it seems from that excerpt they are added automatically

The answer here is git commit -m “LEARTES”

I deleted a line. Added the file to the staging area. I un-staged the file using $ git reset HEAD scene-2.txt. I made a commit regarding the change of name. When I closed and reopened the file, the line I deleted was still gone. Please help.

this is normale bec, whit git reset HEAD filename command you are removing changes from the staging area, but those changes remain in your working directory.