I have three commits and I tried reverting back to the first commit. In doing that, Git removed two files and I don't know why as they were in the first commit I tried reverting to. If the two files Git removed were in the original commit, why did it remove them?
This is the code I used:
git revert <commit id> and this is the error message:
Removing style.css CONFLICT (modify/delete): pages/services.html deleted in (empty tree) and modified in HEAD. Version HEAD of pages/services.html left in tree. Removing index.html error: could not revert 9b23173... inital commit hint: after resolving the conflicts, mark the corrected paths hint: with 'git add <paths>' or 'git rm <paths>' hint: and commit the result with 'git commit'
git revertreverts a commit, not to a commit. I assume you meant to revert the other commits instead. See also stackoverflow.com/a/4114122git revertis for reverting that commit itself, not "reverting to the commit". You're looking forgit reset --hardor such.git revert HEAD HEAD~1to revert the current commit and the previous one. You can also use commit ranges, etc.git checkoutto view the repository state at the commit, while leaving your history intact (where branches are, etc.)