Git Manage Remotes

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 :

[[email protected] /]# cd /usr/src/kodekloudrepos/demo
[[email protected] demo]# git remote add dev_demo /opt/xfusioncorp_demo.git
[[email protected] 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)
[[email protected] demo]# git init
Reinitialized existing Git repository in /usr/src/kodekloudrepos/demo/.git/
[[email protected] tmp]# cd /usr/src/kodekloudrepos/demo/
[[email protected] demo]# ls
info.txt
[[email protected] demo]# cp /tmp/index.html .
[[email protected] demo]# ls
index.html info.txt
[[email protected] demo]# git add index.html 
[[email protected] demo]# git commit -m "add file"
[master 7d92818] add file
1 file changed, 10 insertions(+)
create mode 100644 index.html
[[email protected] 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
[[email protected] demo]#

Leave a Reply

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