Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Introduction to Git Managing Committed Files Discarding File Modifications

tomtrnka
tomtrnka
9,780 Points

git restore <file>.. to discard changes in working directory

Why does my GIT prompts me to use:

git restore <file>

to discard changes in working directory, when in the video, we use:

git checkout ???

Is the video old? (used with older version of git?).

Hi!

I'm also doing this tutorial and I do get the git checkout -- <file> command, so I don't think you're facing a version problem. Maybe you're typing something different?

Steven Vallarsa
seal-mask
.a{fill-rule:evenodd;}techdegree
Steven Vallarsa
Full Stack JavaScript Techdegree Student 14,699 Points

This is apparently the old syntax for accomplishing this task. I still see in the videos they're using "master" instead of "main" that's been the standard for the past two years, so these videos are pretty old.

2 Answers

Rafael Gomes
Rafael Gomes
6,963 Points

I ran into this same thing and a quick googling led me to understand that 'checkout' is an older way of doing it that also has other actions we haven't learned about at this point in the git course (related to branches). This video should be updated to use 'restore'.

More about it: https://stackoverflow.com/questions/61130412/what-is-the-difference-between-git-checkout-vs-git-restore-for-reverting-un

Anton Paluykh
Anton Paluykh
8,994 Points

I have the same issues in VS Code. I have checked both variants) They work in the same way.