How to cancel git add file



After using git add, the file has been added to the staging, we can use git reset HEAD to cancel the staging of the specified file

In the demo, we will unstage the file "test.txt"


git reset HEAD test.txt


reset :  Reset current HEAD to the specified state


Unstaged changes after reset:
M       test.txt
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.