Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+16 votes
asked in CSC305 Fall 2022 by (4.9k points)

1 Answer

+8 votes

Yes, but it's usually not recommended, especially if you have already pushed your changes up to GitHub.

Instead of actually removing a commit, you usually "revert" a commit. The "git revert" command actually produces a new commit which performs the actions necessary to undo the earlier commit. This way, you have a record that the mistaken change was made earlier, and that it was then corrected, instead of just rewinding into the past.

This approach is usually safer, because it means that if you later realized that there was something useful in that mistake commit after all, you could still go back and look at it.

For more detail, see: https://www.theserverside.com/tutorial/How-to-git-revert-a-commit-A-simple-undo-changes-example

answered by (17.9k points)
...