100-Days-Of-DevOps-Challenge-KodeKloud

Git Branch Merge

The Nautilus application development team has been working on a project repository /opt/demo.git. This repo is cloned at /usr/src/kodekloudrepos on storage server in Stratos DC. They recently shared the following requirements with DevOps team:

Create a new branch nautilus in /usr/src/kodekloudrepos/demo repo from master and copy the /tmp/index.html file (present on storage server itself) into the repo. Further, add/commit this file in the new branch and merge back that branch into master branch. Finally, push the changes to the origin for both of the branches.

Steps

1, Login into Storage server

```sh
ssh user@storage-server
```
  1. Move into repository:

     sudo su
     cd /usr/src/kodekloudrepos/demo
    
  2. Create a new branch

     # ensure current branch is master branch
     git branch
     # create a new branch
     git checkout -b nautilus
    
  3. Copy files

     cp /tmp/index.html .
    
  4. Commit changes

     git add .
     git commit -m "added tmp file"
    
  5. Switch to master branch

     git switch master
    
  6. Finally Merge nautilus branch and push chnages

     git merge nautilus
     git push
    

Good to Know?

Git Merge Types

Merge Workflow

  1. Switch to Target: Checkout branch to merge into
  2. Merge Source: git merge source-branch
  3. Resolve Conflicts: Fix any merge conflicts
  4. Commit: Complete merge with commit
  5. Push: Upload changes to remote repository

Conflict Resolution

Best Practices