Surviving the Git Storm: A Complete DevOps Workflow

In the world of DevOps, Git mastery is non-negotiable. This comprehensive tutorial walks through a realistic development scenario that starts from scratch and transforms common mistakes into a professional workflow. We'll experience merge conflicts, security issues, messy history, and emergency fixes—then systematically resolve them using industry-standard Git practices.
Phase 1: Project Setup & Initial Development
Step 1: Create Project and Initial Commit
Objective: Set up a new Git repository with proper structure and connect it to a remote repository.
Steps:
- Create project directory:
mkdir git-storm-project
cd git-storm-project
- Open in VS Code:
code .
- In VS Code terminal, initialize Git repository:
git init
- Create and verify project documentation:
echo "# Project Storm - User Management System" > README.md
ls -la
Explanation: The ls -la command verifies that README.md was created successfully.
- Make initial commit:
git add README.md
git commit -m "feat: initialize project with documentation"
- Verify the commit was created:
git log --oneline
You should see one commit with the message "feat: initialize project with documentation".

- Rename branch to main (if needed):
git branch -M main
- Connect to remote repository (create on GitHub/GitLab first):
git remote add origin https://github.com/Joel5040/Project-Storm.git
- Push to remote repository:
git push -u origin main
The -u flag sets upstream tracking so future pushes can use just git push.

Verification: Check your GitHub repository to confirm the files appear.

Step 2: Develop Feature with Common Mistakes
Objective: Create a feature branch and simulate typical development patterns including security mistakes.
Detailed Steps:
- Create and switch to feature branch:
git checkout -b feature/user-dashboard
- Create first component - normal development:
echo "console.log('User dashboard loaded');" > dashboard.js
git add dashboard.js
git commit -m "Add dashboard component"

- Create problematic commit with sensitive data:
echo "API_KEY=secret123456" > .env
echo "DB_PASSWORD=temp-password-123" >> .env
git add .env
git commit -m "Add environment configuration"
This simulates a common security mistake that we'll fix later.

- Create additional feature work:
mkdir src
echo "function getUserData() { return { name: 'John' }; }" > src/user.js
git add src/user.js
git commit -m "Implement user data functions"
- Verify your work:
git log --oneline
You should see 3 new commits on top of your initial commit.

Phase 2: Team Collaboration Challenges
Step 3: Simulate Teammate's Changes
Objective: Experience handling remote changes from other team members while working on a feature.
Detailed Steps:
- Switch to main branch:
git checkout main
- Simulate teammate adding project structure:
cat > index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<title>Project Storm</title>
</head>
<body>
<!-- Navigation added by team -->
<nav>Home | Dashboard | Profile</nav>
<h1>Welcome to Project Storm</h1>
</body>
</html>
EOF

- Commit and push teammate's work:
git add index.html
git commit -m "feat: add basic website structure with navigation"
git push origin main
- Verify the remote is updated:
git log --oneline

Step 4: Handle Uncommitted Work During Sync
Objective: Learn to manage uncommitted work when you need to sync with team changes.
Detailed Steps:
- Return to feature branch:
git checkout feature/user-dashboard
- Create uncommitted work:
echo "/* Dashboard Styles */
.dashboard-container {
padding: 20px;
background: #f5f5f5;
}" > styles.css
- Check status to see uncommitted changes:
git status
You should see styles.css as an untracked file.

- Stash uncommitted work safely:
git stash push -m "WIP: dashboard styling"

- Verify stash worked:
git status
The working directory should now be clean.

- Get latest changes from main branch:
git fetch origin
git rebase origin/main
- If conflicts occur during rebase:
# Edit the conflicted files in VS Code
# After resolving conflicts:
git add .
git rebase --continue
- Restore your stashed work:
git stash pop
- Commit the stashed work:
git add styles.css
git commit -m "Add dashboard styling"
Phase 3: History Cleaning & Security Remediation
Step 5: Fix Security Issues Professionally
Objective: Discover and resolve security mistakes without creating noise in the commit history.
Detailed Steps:
- Identify the security issue in history:
git log --oneline -5
Look for the commit that added the .env file with secrets.
- Remove sensitive data from environment file:
echo "# Environment Configuration Template
# Add actual values in deployment environment
API_KEY=your-api-key-here
DB_PASSWORD=your-database-password-here" > .env
- Amend the commit to fix the security issue:
git add .env
git commit --amend -m "feat: add environment configuration template"

- Verify the fix:
git log --oneline
cat .env
The commit message should be updated and the .env file should no longer contain real secrets.
Step 6: Create Clean, Atomic History
Objective: Transform multiple messy commits into a single, coherent feature commit.
Detailed Steps:
- View current branch history:
git log --oneline
Note the commit hashes for the last 3-4 commits.
- Start interactive rebase:
git rebase -i HEAD~4
- In the interactive rebase editor:
pick abc1234 Add dashboard component
squash def5678 Add environment configuration
squash ghi9012 Implement user data functions
squash jkl3456 Add dashboard styling
- After saving, provide comprehensive commit message:
feat: implement user dashboard system
- Add dashboard JavaScript component with core functionality
- Include environment configuration template for secure deployment
- Implement user data management functions
- Add responsive styling for dashboard container
Security: Removed hardcoded credentials in favor of template
Testing: Manual review of dashboard functionality
- Verify the clean history:
git log --oneline
You should see one clean commit instead of multiple small ones.
Phase 4: Project Hygiene & Ignoring Files
Step 7: Establish Professional Gitignore
Objective: Prevent future mistakes by properly configuring which files Git should ignore.
Detailed Steps:
- Create comprehensive .gitignore file:
cat > .gitignore << 'EOF'
# Environment variables (never commit secrets!)
.env
.env.local
.env.production
*.cfg
# Log files
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Dependency directories
node_modules/
jspm_packages/
# Build outputs
/dist/
/build/
/out/
# IDE and editor files
.vscode/
.idea/
*.swp
*.swo
# OS metadata
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Thumbs.db
EOF
- Test the gitignore with files that should be ignored:
touch .env.local debug.log production.cfg
mkdir node_modules dist
touch node_modules/package.json dist/bundle.js
- Commit the gitignore:
git add .gitignore
git commit -m "chore: establish comprehensive gitignore rules"
- Verify ignored files are properly excluded:
git status
You should only see .gitignore in the changes, not the test files we created.
Phase 5: Code Review & Integration
Step 8: Push and Prepare for Review
Objective: Share your work with the team following best practices.
Detailed Steps:
- Push feature branch to remote:
git push -u origin feature/user-dashboard
- If history was rewritten during rebase, update safely:
git push --force-with-lease origin feature/user-dashboard

- Verify remote branch:
git branch -r

Step 9: Simulate Code Review Process
Objective: Practice the integration workflow used in professional environments.
Detailed Steps:
- Switch to main branch for integration:
git checkout main
- Pull latest changes from team:
git pull origin main
- Merge feature with descriptive message:
git merge --no-ff feature/user-dashboard -m "feat: integrate user dashboard system
- Adds responsive user dashboard component
- Includes secure environment configuration
- Implements user data management functions
- Adds comprehensive styling
Testing: Manual review of dashboard functionality
Security: Environment template prevents credential exposure"

- Push the integrated changes:
git push origin main
Phase 6: Emergency Response & Maintenance
Step 10: Handle Critical Production Issue
Objective: Simulate an emergency hotfix scenario that requires immediate attention.
Detailed Steps:
- Create hotfix branch from main:
git checkout -b hotfix/welcome-message main
- Introduce and discover a critical typo:
echo "Welcoe to Project Storm! We're excited to have you." > welcome.txt
git add welcome.txt
git commit -m "Add welcome message"

- Discover and fix the critical typo immediately:
echo "Welcome to Project Storm! We're excited to have you." > welcome.txt
git add welcome.txt
git commit --amend -m "fix: correct critical welcome message typo"
- Verify the fix:
cat welcome.txt
git log --oneline
The file should show the correct spelling and history should show one clean commit.
Step 11: Deploy Hotfix and Cleanup
Objective: Complete the emergency fix and maintain repository hygiene.
Detailed Steps:
- Integrate hotfix into main branch:
git checkout main
git merge hotfix/welcome-message
- Push the hotfix:
git push origin main

- Clean up local branches:
git branch -d feature/user-dashboard
git branch -d hotfix/welcome-message
- Remove remote feature branch:
git push origin --delete feature/user-dashboard
- Verify cleanup:
git branch -a
You should only see main and remote/main branches.

Conclusion
Key Workflows Mastered
1. Complete Feature Development Cycle
Proper repository initialization and remote setup
Branch isolation for feature work
Atomic commit practices with meaningful messages
Regular synchronization with main branch
2. Security Incident Response
Identification of sensitive data in commits
Safe remediation using amend without history pollution
Prevention through comprehensive gitignore configuration
Template-based approach for configuration files
3. Professional History Management
Interactive rebase for clean, logical history
Commit squashing for feature cohesion
Meaningful commit messages for team clarity
Safe history rewriting with force-with-lease
4. Emergency Response Protocol
Hotfix branch strategy for critical issues
Rapid typo correction with amend
Safe integration with main branch
Proper branch lifecycle management
5. Repository Maintenance Excellence
Systematic branch cleanup post-merge
Remote repository synchronization
Working directory hygiene practices
Comprehensive status verification
Professional Standards Achieved
Security First: Never commit credentials, use templates and gitignore
Atomic Commits: Single responsibility per commit with clear messages
Clean History: Linear, readable history for team collaboration
Safe Practices: Force-with-lease instead of dangerous force pushes
Branch Hygiene: Proper lifecycle management from creation to deletion
Comprehensive Verification: Multiple checkpoints to ensure repository health
This workflow transforms you from someone who knows Git commands to someone who understands Git strategy—the essential mark of a true DevOps professional. The patterns practiced here will enable you to handle any version control challenge with confidence and maintain clean, secure, and collaborative repositories throughout your career.



