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

git checkout -- <filename>

Does git checkout -- <filename> checkout at the commit stage and save the change automatically through committing it?

git checkout -- <filename> = git checkout HEAD <filename>

Thank you

1 Answer

Hi Hanwen!

I Googled your question and got this:

The git checkout command lets you navigate between the branches created by git branch . Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch.

More info:

https://git-scm.com/docs/git-checkout

https://www.atlassian.com/git/tutorials/using-branches/git-checkout

https://careerkarma.com/blog/git-checkout/

I hope that helps.

Stay safe and happy coding!

Thank you for your information Peter