Reverting the Latest Commit in a Git Repository
The Nautilus application development team reported issues with recent changes in the /usr/src/kodekloudrepos/media
repository. The DevOps team was tasked with reverting the latest commit and restoring the repository to its previous state, while recording the change with a new commit message.
Steps Performed
- Navigate to the repository
cd /usr/src/kodekloudrepos/media
- Check commit history
git log --oneline
Output showed:
89baa1d add data.txt file
b67c5f6 initial commit
- Revert the latest commit
git revert HEAD --no-edit
This created a revert commit but with the default message Revert "add data.txt file"
.
-
Amend the commit message
The requirement was to use all lowercase
revert media
, so the commit was amended:
git commit --amend -m "revert media"
- Verify the history
git log --oneline
Final output:
04ee874 revert media
89baa1d add data.txt file
b67c5f6 initial commit
Top comments (0)