Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.4k points)

After the last commit, I modified a bunch of files in my working copy, but I want to undo the changes to one of those files, as in reset it to the same state as the most recent commit.

However, I only want to undo the working copy changes of just that one file alone, nothing else with it.

How do I do that?

1 Answer

0 votes
by (27.5k points)
edited by

Use the following command: 

git checkout -- filename

Using '--' is a good practice to avoid the confusion between branch name and filename.

Browse Categories