I recently applied a patch to my repo which I afterwards realized was the wrong thing to do. I applied the patch with the "--reject" parameter, so it applied the changes that worked and created .rej files for the rest.
I am fairly new to git, so I may not have gone back the right way because now I am back to a previous commit and everything is working fine, except I have a lot of .rej files scattered around my code base. I went back to a previous commit and did a "git reset --hard" to get rid of all the files that applying the patch checked out.
I can't find any information on why I still have these .rej files even though I have nothing checked out. I know that I probably went about reverting from the patch incorrectly, and it seems that there is usually a better alternative to applying a patch anyways, but does anyone know the proper way to get rid of these rejects?
Thank you!
Like most git commands, git reset --hard
doesn't touch files that git doesn't know about.
To delete them manually, first use git clean -n
to show all files in the working directory that are not tracked by git. Make sure there's nothing listed that you want to keep. Then use git clean -f
to actually delete the files.
There are two options you might want to know about:
git clean -xf
also removes files ignored by git
git clean -df
also removes untracked directories
git clean
may do what you want.
Or you can remove files manually with find . -name \*.rej | xargs rm
.
Or you can remove all files, except .git in your repo and then do git checkout .
which will restore the files under source control.
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