I made some changes on my local machine and I don't want to keep them.
When I perform a pull to get the recent changes from the server I get a message saying that I have unstaged changes and I must commit or stash them.
But I don't want to do it. I want to cancel them. How to do this?
git checkout . to undo all non-commited changes on tracked files.
git clean -f to remove non-commited files.
PS: . in git checkout . is shell wildcard that means "all files within current directories and subdirectories". You can use any wildcard or path (git checkout path/ or git checkout ./*.py)
git reset --hard
Will revert your repository to a clean state.
git reset <commit> Will change the index to point at that commit, by default it's HEAD, so your most recent commit.
The --hard flag will also revert any files to what they were at that commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With