Git hard reset
Tasks
- Navigate to - /usr/src/kodekloudrepos/demogit repository on the Storage server.
- Reset the repository so that only two commits remain: - initial commit
- add data.txt file
 
- Make sure the working directory and HEAD are aligned to - add data.txt file.
- Push the updated state to the remote, replacing existing history. 
Steps
1
SSH to storage server and switch to root if needed
ssh natasha@ststor01
sudo su -3
Find the commit hash for "add data.txt file"
git log --oneline
4
Reset to "add data.txt file"
git rebase -i --root
5
Keep only:
- initial commit
- add data.txt file
(Delete or drop other commits in the interactive editor)
git rebase -i --root6
Force push cleaned-up history
git push origin master --force7
Verify only two commits remain
git log --oneline
Last updated