Languages

Git reset 1 commit / revert last commit

2 points
Asked by:
daniell
490

How can I reset 1 commit back with Git?

I don't want to keep anything eg any local files not commited etc, I just want to roll back 1 commit.

Nothing else, nothing more.

Thanks for the answer.

1 answer
2 points
Answered by:
Root-ssh
178180

Quick solution:

Practical example:

Take a look at this screenshot, flow:

  1. git log show us 2 commits
  2. We execute:
    git reset --hard HEAD~1
  3. git log show us 1 commit, because we removed 1 commit

People somethimes call git reset:

  • rollback 1 commit
  • revert 1 commit
  • remove 1 commit from git history
  • undo last commit

:)

0 commentsAdd comment
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.
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