Skip to content

Latest commit

 

History

History
118 lines (85 loc) · 3.21 KB

Git Manage Remotes.md

File metadata and controls

118 lines (85 loc) · 3.21 KB

Problem Statement

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

  1. Login to the Storage Server and Switch to Root User:

    • Connect to the storage server and elevate to the root user.
    ssh natasha@ststor01
    sudo su
  2. Navigate to the Repository Directory:

    • Change to the directory where the Git repository is located.
    cd /usr/src/kodekloudrepos/demo/
  3. Check the Existing Git Remotes:

    • List the current remotes to verify existing configurations.
    git remote -v

    Expected Output:

    origin  /opt/demo.git (fetch)
    origin  /opt/demo.git (push)
    
  4. Add a New Remote Named dev_demo:

    • Add a new remote named dev_demo that points to the /opt/xfusioncorp_demo.git repository.
    git remote add dev_demo /opt/xfusioncorp_demo.git
  5. Verify the New Remote Configuration:

    • List the remotes again to ensure that the new remote has been added correctly.
    git remote -v

    Expected Output:

    origin  /opt/demo.git (fetch)
    origin  /opt/demo.git (push)
    dev_demo  /opt/xfusioncorp_demo.git (fetch)
    dev_demo  /opt/xfusioncorp_demo.git (push)
    
  6. Copy the File index.html into the Repository:

    • Copy the index.html file from /tmp to the repository directory.
    cp /tmp/index.html /usr/src/kodekloudrepos/demo/
    • Verify that the file has been successfully copied.
    ls -al index.html

    Expected Output:

    -rw-r--r-- 1 root root 1234 Aug 13 08:01 index.html
    
  7. Add and Commit the Changes:

    • Stage the new file for commit and commit the changes to the master branch.
    git add index.html
    git commit -m "Added index.html to master branch"

    Expected Output:

    [master 64ad743] Added index.html to master branch
     1 file changed, 10 insertions(+)
     create mode 100644 index.html
    
  8. Push the master Branch to the New Remote:

    • Push the changes in the master branch to the new remote dev_demo.
    git push dev_demo master

    Expected Output:

    Enumerating objects: 6, done.
    Counting objects: 100% (6/6), done.
    Delta compression using up to 36 threads
    Compressing objects: 100% (4/4), done.
    Writing objects: 100% (6/6), 584 bytes | 584.00 KiB/s, done.
    Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
    To /opt/xfusioncorp_demo.git
     * [new branch]      master -> master