Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 731 Bytes

File metadata and controls

29 lines (19 loc) · 731 Bytes

Remove Last Commit and Discard Changes

Company: Gitlab | Difficulty: Easy


Scenario

You have created a commit locally that contains incorrect changes and you want to completely erase it from history.

Task

Navigate to /home/interview/repo. Remove the last commit entirely and discard all associated file changes.

Example

# Before (Bad commit exists)
$ git log --oneline -2
c3d4e5f (HEAD -> main) Bad commit - wrong changes
b2c3d4e Add feature implementation

# After (Clean history)
$ git log --oneline -2
b2c3d4e (HEAD -> main) Add feature implementation

📹 Video Solution