I accidentally removed a couple of files from a repository, made a commit and pushed it to a github repository. I’d like to get the files back and commit, and push the files back to the online repository. How can I go about doing that?
I tried checking out and cloning the second last commit into a seperate folder locally — however, im not sure how to proceed from there.
You can do a
git revert {commit #}which will revert that commit, and you can just push to github.If you don’t want to revert, you could also do
git checkout {commit #} -- file1 file2 file3 ...to check out the files you want to revert directly as new changes in your current branch, commit them, and push.