Introduction
Modern DevOps teams rely on strong source code management practices to deliver software quickly safely and consistently. At the center of this process is branching and merging the workflow that allows multiple developers to work in parallel without breaking production systems.
In this hands on lab project you will simulate how real world DevOps teams manage code changes from development to production using Git. You will practice creating feature branches synchronizing with the main branch resolving changes and merging code using industry best practices.
This project is designed to help you move beyond theory and experience how professional teams collaborate test and ship code in a controlled production safe environment. By the end of this lab you will understand not just how branching works but why it is critical to DevOps success.
Project Objectives
By completing this project you will be able to
- Understand the importance of branching in DevOps workflows
- Learn why teams avoid working directly on the main branch and how branching reduces risk
- Create and manage feature branches effectively
- Develop new features in isolated environments without disrupting
** Step 1: Prepare Your Repository**
Run:
git clone https://github.com/Subair-09/Stylish-E-commerce.git (This command downloads a copy of the project from GitHub to your local machine.) and Git creates a new folder called Stylish-E-commerce
cd Stylish-E-commerce (This command moves you into the project folder so you can run Git commands inside it. Without this step, Git will not know which project you are working on.)
git checkout main (This command switches you to the main branch of the project.)
git pull (This command updates your local main branch with the latest changes from GitHub.)
Checkpoint: git status shows a clean working tree
Step 2: Create a Feature Branch
git checkout -b feature/amazing-feature
This command creates a new branch and immediately switches you to it.
It does two things at once:
- Creates a new branch
- The branch name is feature/amazing-feature
- This branch is used to work on a new feature
- It is separate from the main branch, so your changes are safe
- Switches to the new branch
- After running the command, you are no longer on main
- Any changes you make now happen only in this feature branch
Step 3: Make a Change
- Edit a file OR
- Add a new feature OR
- Improve documentation
add a file feature.html by using the command
New-item or touch feature.html
use the command code . (This command opens the current folder in Visual Studio Code.)
use the command git status
Checkpoint: Files appear as modified or new
Step 4: Commit Your Work
git add .
This command tells Git to stage all the changes you have made in the project for the next commit.
- What it does:
- Adds all modified files
- Adds new files
- Prepares them to be saved in Git history
- The dot . means:
- “Add everything in this folder and subfolders.”
git commit -m "Add amazing feature"
This command saves your staged changes into Git with a message describing what you did.
- What it does:
- Creates a new commit (a snapshot of your code)
- Records the changes permanently in Git history
- Adds a clear message so others understand your work
- The -m flag means:
- “Use this message to describe the change.”
Checkpoint: Commit created successfully
Step 5: Sync With Main
git checkout main
- This command switches you to the main branch, which contains the stable and production ready version of the code.
- You do this to make sure you are working from the correct base before updating or merging anything.
git pull
This command updates your local main branch with the latest changes from the remote repository (GitHub).
It:
- fetches new commits from GitHub
- merges them into your local main
- ensures your local main is up to date
- This is important so you don’t work with outdated code.
git checkout feature/amazing-feature
- This command switches you to your feature branch, where you are developing new functionality.
- At this point, your feature branch may be behind main, which is why the next step is important.
git merge main
- This command merges the latest changes from main into your feature branch.
Step 6: Merge to Main
git checkout main
This command switches you to the main branch, which contains the production ready and stable version of the code.
You must be on the branch you want to receive the changes before merging.
git merge feature/amazing-feature
This command merges the work from the feature/amazing-feature branch into the main branch.
** Step 7: Clean Up**
git branch -d feature/amazing-feature
This command deletes the feature branch called feature/amazing-feature from your local repository.
Conclusion
In this lab project, you practiced how real DevOps teams manage code changes safely and efficiently using Git branching and merging workflows. By working with feature branches, synchronizing with the main branch, and merging only tested changes, you experienced how teams protect production systems while still moving fast.
This project demonstrated why the main branch must always remain stable and why all development should happen in isolated branches. You also learned how frequent integration, clear commits, and branch cleanup help reduce risk, improve collaboration, and keep codebases production ready.
By completing this lab, you have built a strong foundation in source code management that directly supports CI/CD pipelines, team collaboration, and modern DevOps practices. These skills are essential for working in real world engineering teams where stability, speed, and reliability matter.
You are now ready to apply this workflow in larger projects, automate it with pipelines, and collaborate confidently in any DevOps environment.









Top comments (0)