Languages

Git reset 1 commit / revert last commit

2 points
Asked by:
AnnLen
9090

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:
AnnLen
9090

Quick solution:

git reset --hard HEAD~1

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 comments Add comment
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join