Development Tools Introduction to Git Managing Committed Files Discarding File Modifications

Hanwen Zhang
Hanwen Zhang
17,774 Points

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!

Hanwen Zhang
Hanwen Zhang
17,774 Points

Thank you for your information Peter