Git commit id

broken image
broken image

Make sure you only use it to get rid of commits that haven't been pushed to another repository! This can cause some serious headaches if any of those lost commits have been pushed to a public repository. Ī note of warning that git reset will alter history - if I made several commits and then reset to the first commit, the subsequent commits will no longer be in the commit history. With the -hard option, it replaces the contents of your working directory with what was on. If you want to set your branch to the state of a particular commit (as implied by the OP), you can use git reset, or git reset -hard The first option only updates the INDEX, leaving files in your working directory unchanged as if you had made the edits but not yet committed them.

broken image

It's more or less a way to 'undo' a commit and save that undo in your history as a new commit. The above answer is not quite correct - git revert does not set your repository to that commit - git revert creates a new commit that undoes the changes introduced by commit.

broken image