Languages
[Edit]
EN

Git - rollback commit (using git reset --hard)

4 points
Created by:
Root-ssh
178240

In this quick article we would like to show how to rollback pushed commmit with git with git reset --hard command.

Quick solution:

Note: --hard parameter is optional.

 

Full example

Edit

In this section you can see full example how to rollback commit with git reset --hard.

Note: using this approach, it is good to notify other people in team about rolling back to previous version.

Simple steps:

  1. find commit hash you want to recover
     
  2. reset changed to proper commit
    (e.g. we want to recover source code to 465755bead3d3afe386e702540644427c250bcb0)
     
  3. pushing changes with --force
    Note: notify other team members that you push your changes to remote repository.

 

Alternative titles

  1. Git - revert commit (using git reset --hard)
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Git

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join