DEV Community

Wycliffe A. Onyango
Wycliffe A. Onyango

Posted on

100 Days of DevOps: Day 24

Branch Creation

Objective

Create a new Git branch named xfusioncorp_blog from the master branch in the /usr/src/kodekloudrepos/blog repository on the Storage server. This branch will be used by the development team to implement new features, while ensuring the current production code remains unaffected.

Environment

  • Server: Storage Server (ststor01)
  • Repository Path: /usr/src/kodekloudrepos/blog
  • Branch Created: xfusioncorp_blog
  • Base Branch: master
  • User: natasha (operations performed with sudo due to repository ownership)

Implementation Steps

  1. Navigate to the repository:
   cd /usr/src/kodekloudrepos/blog
Enter fullscreen mode Exit fullscreen mode
  1. Switch to the master branch:
   sudo git checkout master
Enter fullscreen mode Exit fullscreen mode
  1. Create and switch to the new branch xfusioncorp_blog:
   sudo git checkout -b xfusioncorp_blog
Enter fullscreen mode Exit fullscreen mode
  1. Push the new branch to the remote repository:
   sudo git push origin xfusioncorp_blog
Enter fullscreen mode Exit fullscreen mode

Verification

  • Verified the branch exists locally:
  sudo git branch
Enter fullscreen mode Exit fullscreen mode

Output included:

  * xfusioncorp_blog
    master
Enter fullscreen mode Exit fullscreen mode
  • Verified the branch was successfully pushed to the remote:
  sudo git branch -r
Enter fullscreen mode Exit fullscreen mode

Output included:

  origin/master
  origin/xfusioncorp_blog
Enter fullscreen mode Exit fullscreen mode

Issues Faced / Lessons Learned

  1. Dubious Ownership Warning
  • Git flagged the repository as a “dubious ownership” directory since it was owned by root.
  • Resolution: Added the path as a safe directory:

     git config --global --add safe.directory /usr/src/kodekloudrepos/blog
    
  1. Permission Denied on .git/index.lock
  • As the repository files were owned by root, write access was denied to the natasha user.
  • Resolution: Executed all Git commands with sudo to gain the required permissions.
  1. Lesson Learned
  • When working with shared or system-owned repositories, always check directory ownership and permissions first.
  • Using sudo is acceptable for one-off administrative tasks, but adjusting ownership (chown) may be preferable for long-term developer use.
  • The safe.directory configuration is essential when Git detects mismatched user permissions in newer versions.

Result

The branch xfusioncorp_blog has been successfully created from master and pushed to the remote repository. All operations were completed without modifying the project code.

Top comments (0)