I don’t know what happened but I messed up the Git repo again. So all was OK , it was compiling fine. Not compiling now. I had made some changes, not committed any. When I do repo diff I see the changes I made and some weird changes have come into the code. I don’t know! Lot of them. So now I think inorder to fix this and keep the changes I deliberately made and the changes that appear from no where. I will do git add the changes I made and I want to discard all the changes that otherwise appear. How to do this ?
git add filepath
And how to discard what I don’t want to add and commit?
You can do the following steps:
git addto add the changes you want to keep.git committhose changes to the repository.git reset --hard HEADto throw away the rest of the changes.Note that step 3 is destructive and you can’t use Git to recover those changes. Make a backup first if you’re unsure.