Question : The Nautilus application development team has been working on a project repository /opt/official.git. This repo is cloned at /usr/src/kodekloudrepos on storage server in Stratos DC. They recently shared the following requirements with DevOps team:
a. Create a new branch devops in /usr/src/kodekloudrepos/official repo from master and copy the /tmp/index.html file (on storage server itself). Add/commit this file in the new branch and merge back that branch to the master branch. Finally, push the changes to origin for both of the branches.
1. At first login on to the storage server & switch to the 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/official/ total 8 -rw-r--r-- 1 root root 34 Jul 19 16:18 info.txt -rw-r--r-- 1 root root 26 Jul 19 16:18 welcome.txt [root@ststor01 ~]# [root@ststor01 ~]# cd /usr/src/kodekloudrepos/official/ [root@ststor01 ~]# [root@ststor01 official]# git status # On branch master nothing to commit, working directory clean [root@ststor01 official]# |
3. Create a new branch as per the task from the master repo
[root@ststor01
official]# git checkout -b devops Switched to a
new branch 'devops' [root@ststor01
official]# [root@ststor01
official]# git status # On branch
devops nothing to
commit, working directory clean [root@ststor01 official]# |
4. Check new branch status & copy the index file
[root@ststor01
official]# git branch * devops master [root@ststor01
official]# [root@ststor01
official]# cp /tmp/index.html
/usr/src/kodekloudrepos/official/ [root@ststor01
official]# [root@ststor01
official]# ll /usr/src/kodekloudrepos/official/ total 12 -rw-r--r-- 1
root root 27 Jul 19 16:28 index.html -rw-r--r-- 1
root root 34 Jul 19 16:18 info.txt -rw-r--r-- 1
root root 26 Jul 19 16:18 welcome.txt [root@ststor01
official]# |
5. Git add , Commit Index.html file
[root@ststor01 official]# git add index.html
[root@ststor01
official]# git commit -m "add official" [devops ac4e417]
add official 1 file changed, 1 insertion(+) create mode 100644 index.html [root@ststor01 official]# |
6. Git Checkout master & merge to new branch
[root@ststor01 official]# git checkout master Switched to branch 'master' [root@ststor01 official]# [root@ststor01 official]# git merge devops Updating f85139b..ac4e417 Fast-forward index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 index.html [root@ststor01 official]# |
7. Git push to the branch as well master
[root@ststor01 official]# git push -u origin devops Counting objects: 4, done. Delta compression using up to 48 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 328 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To /opt/official.git * [new branch] devops ->
devops Branch devops set up to track remote branch devops from origin. [root@ststor01 official]# [root@ststor01 official]# [root@ststor01 official]# git push -u origin master Total 0 (delta 0), reused 0 (delta 0) To /opt/official.git f85139b..ac4e417 master -> master Branch master set up to track remote branch master from origin. [root@ststor01 official]# [root@ststor01 official]# git status # On branch master nothing to commit, working directory clean [root@ststor01 official]# |
8. Click on Finish & Confirm to complete the task successfully
0 Comments