Git Manage Remotes

Task :

The xFusionCorp development team added updates to the project that is maintained under /opt/demo.git repo and cloned under /usr/src/kodekloudrepos/demo. Recently some changes were made on Git server that is hosted on Storage server in Stratos DC. The DevOps team added some new Git remotes, so we need to update remote on /usr/src/kodekloudrepos/demo repository as per details mentioned below:

a. In /usr/src/kodekloudrepos/demo repo add a new remote dev_demo and point it to /opt/xfusioncorp_demo.git repository.

b. There is a file /tmp/index.html on same server; copy this file to the repo and add/commit to master branch.

c. Finally push master branch to this new remote origin.

Solution :

[root@ststor01 /]# cd /usr/src/kodekloudrepos/demo
[root@ststor01 demo]# git remote add dev_demo /opt/xfusioncorp_demo.git
[root@ststor01 demo]# git remote -v
dev_demo /opt/xfusioncorp_demo.git (fetch)
dev_demo /opt/xfusioncorp_demo.git (push)
origin /opt/demo.git (fetch)
origin /opt/demo.git (push)
[root@ststor01 demo]# git init
Reinitialized existing Git repository in /usr/src/kodekloudrepos/demo/.git/
[root@ststor01 tmp]# cd /usr/src/kodekloudrepos/demo/
[root@ststor01 demo]# ls
[root@ststor01 demo]# cp /tmp/index.html .
[root@ststor01 demo]# ls
index.html info.txt
[root@ststor01 demo]# git add index.html 
[root@ststor01 demo]# git commit -m "add file"
[master 7d92818] add file
1 file changed, 10 insertions(+)
create mode 100644 index.html
[root@ststor01 demo]# git push dev_demo master
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 578 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
To /opt/xfusioncorp_demo.git
* [new branch] master -> master
[root@ststor01 demo]#

Leave a Reply

Your email address will not be published. Required fields are marked *