Lab Information
The Nautilus application development team was working on a git repository /usr/src/kodekloudrepos/news present on Storage server in Stratos DC. However, they reported an issue with the recent commits being pushed to this repo. They have asked the DevOps team to revert repo HEAD to last commit. Below are more details about the task:
In /usr/src/kodekloudrepos/news git repository, revert the latest commit ( HEAD ) to the previous commit (JFYI the previous commit hash should be with initial commit message ).
Use revert news message (please use all small letters for commit message) for the new revert commit.
Lab Solutions
Step-by-Step Solution
- Login to Storage Server
ssh natasha@ststor01.stratos.xfusioncorp.com
# password: Bl@kW
- Switch to root
sudo su -
# password: Bl@kW
- Go to the news repository
cd /usr/src/kodekloudrepos/news
git status
- Check commit history (to confirm HEAD)
git log --oneline --max-count=2
Example output:
abc1234 Latest commit message
def5678 initial commit
๐ abc1234 = HEAD (latest commit)
๐ def5678 = previous commit (initial commit)
- Revert the latest commit
# Run:
git revert HEAD
This will open an editor.
- Set the commit message
Replace everything with exactly:
revert news
Save and exit the editor.
โ ๏ธ Commit message must be all lowercase
โ ๏ธ Do NOT add anything else
- Verify the revert commit
git log --oneline --max-count=3
You should now see:
revert news
abc1234 Latest commit message
def5678 initial commit
Top comments (0)