first-contributions/additional-material/git_workflow_scenarios/resetting-a-commit.md
2022-11-22 01:05:15 +01:00

950 B

Reset a commit

reset is the command which can be used when we want to move the repository back to a previous commit, discarding any changes made after that commit.
The main difference between resetting and reverting a commit is that git reset unstages a file and bring our changes back to the working directory and git revert removes the commits from the remote repository.

git reset can be achieved using following commands:

  • The following command will give summary of all the commits using following two parameters:

    • The first seven characters of the commit hash - this is what we need to refer to in our reset command.
    • the commit message
    git log --oneline
    
  • One can reset repository back to the specific commit using following command:
    git reset commithash where commithash being the first 7 characters of the commit hash we found in the log