How to undo add file in git



When using Git to manage code, you may encounter the following scenarios. The file has been successfully added through git add, and you want to undo this operation. You can use git restore to achieve this operation. In this example, we implement the undo operation on the file that has been successfully added by git


git restore --staged


git :   is a free and open source distributed version control system
restore :   Restore working tree files
-S, --staged :   Specify the restore location. If neither option is specified, by default the working tree is restored. Specifying --staged will only restore the index. Specifying both restores both.

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.