Last Updated on 2021-10-31 by Clay
If you used git add
to trace the items you want to submit, but suddenly you found you add the wrong items... in the first time, you can use git status
to check the add item list, and use git reset
to cancel the item.
Example
Assume that I have submitted and tracked all the items.
git add *
git status
Output:
It can be found that I accidentally added the entire virtual environment venv folder. So if I want to push it on GitHub, it will be very large. If I want to clone and continue working on other devices in the future, I do not want to pull down the entire environment.
In this time, we can use git reset
to cancel the items added.
git reset venv
git status
Output:
Then you can submit with confidence.
References
- https://stackoverflow.com/questions/348170/how-do-i-undo-git-add-before-commit
- https://git-scm.com/docs/git-reset