Question : The Nautilus application development team was working on a git repository /usr/src/kodekloudrepos/demo 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/demo git repository, revert the latest commit ( HEAD ) to the previous commit (JFYI the previous commit hash should be with initial commit message ).
Use revert demo message (please use all small letters for commit message) for the new revert commit.
Please Note :- Perform the below commands based on your question server, user name & other details might differ . So please read task carefully before executing. All the Best 👍
1. At first login on storage server & switch to root user
thor@jump_host /$ ssh natasha@ststor01 The authenticity of host 'ststor01 (172.16.238.15)' can't be established. ECDSA key fingerprint is SHA256:IxwAD3ZVWxJeoVZGlhqWNAp/2Waue9JvaV7Hz6hyyfg. ECDSA key fingerprint is MD5:87:7c:77:5f:04:db:fa:a3:35:82:e6:d9:d4:f0:1c:35. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'ststor01,172.16.238.15' (ECDSA) to the list of known hosts. natasha@ststor01's password: [natasha@ststor01 ~]$ sudo su - We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo] password for natasha: [root@ststor01 ~]# |
2. Check repo git status
[root@ststor01 ~]# ll
/usr/src/kodekloudrepos/demo/ total 4 -rw-r--r-- 1
root root 33 Jul 9 11:54 demo.txt [root@ststor01
~]# [root@ststor01
~]# cd /usr/src/kodekloudrepos/demo/ [root@ststor01
demo]# git status # On branch
master # Untracked
files: # (use "git add <file>..."
to include in what will be committed) # # demo.txt nothing added to
commit but untracked files present (use "git add" to track) [root@ststor01
demo]# |
3. Check Git logs
[root@ststor01 demo]# git log commit 5def588deba64e7bc846b0e841dd11efc404a677 Author: Admin <admin@kodekloud.com> Date: Fri Jul 9 11:54:06 2021 +0000 Author: Admin <admin@kodekloud.com> Date: Fri Jul 9 11:54:06 2021 +0000 [root@ststor01 demo]# |
4. Run command revert HEAD and Add , Commit with given message in task
[root@ststor01
demo]# git revert HEAD [master 277ad10]
Revert "add data.txt file" 1 file changed, 1 insertion(+) create mode 100644 info.txt [root@ststor01
demo]# [root@ststor01
demo]# git add . [root@ststor01
demo]# git commit -m " revert demo " [master
4b49edc] revert demo 1 file changed, 1 insertion(+) create mode 100644 demo.txt [root@ststor01
demo]# |
5. Validate the task
[root@ststor01
demo]# git log commit
4b49edc22ad6c091f0be8f7f9615400eac2b5525 Author: Admin
<admin@kodekloud.com> Date: Fri Jul 9 12:02:37 2021 +0000 revert demo commit 277ad1088ffa43e32f924b11e66ceff48b1aaed6 Author: Admin
<admin@kodekloud.com> Date: Fri Jul 9 12:00:31 2021 +0000 Revert "add data.txt file" This reverts commit 5def588deba64e7bc846b0e841dd11efc404a677. commit 5def588deba64e7bc846b0e841dd11efc404a677 Author: Admin
<admin@kodekloud.com> Date: Fri Jul 9 11:54:06 2021 +0000 add data.txt file commit 6c9a386e81ad9e30adcc98868b7d8e0378a47b93 Author: Admin
<admin@kodekloud.com> Date: Fri Jul 9 11:54:06 2021 +0000 initial commit [root@ststor01
demo]# |
6. Click on Finish & Confirm to complete the task successful
0 Comments