How to discard all local changes in git



In daily development, if you want to quickly discard all the modified content after modifying multiple files, you can discard the local modifications through the following git command. Come and learn.


git checkout .


This command is for all local file modifications. If you want to modify a single file, you can try this, for example, to discard the modified content of test.txt:
git checkout test.txt


git :  is a free and open source distributed version control system
checkout :  switch branches or restore working tree files
Was this helpful?

I hope to help every developer quickly find the commands they need. Of course, you can also add your own commonly used commands for easy searching.