Lets Git Good Together

30 Minutes to Git Good

30-MINUTE WORKSHOP

Git Good Together

A hands-on Git workshop with real chaos, real fixes, and real exercises.

Beginner-Intermediate
30 Minutes
5 Sections
50 Total Marks

Why Does Git Even Exist?

Setting the stage with a painful story everyone recognises

Real Team Scenario

Meet the "DSP-backend" team: Ravi (dsp), Isha (dsp), Dhaval (QA), and Radhika (DevOps).


It's a Friday! Ravi sends final_api_v3_FINAL_USE_THIS.zip on Teams to Isha. Isha accidentally overwrites Ravi's API fix while editing the same file. Dhaval can't reproduce a bug because he doesn't know which version he's testing. Radhika is furious in the corner.


Git is the solution to this exact chaos. It's a version control system - like a magical "time machine + collaboration hub" for your code.

Ravi · Backend
Isha · Frontend
Dhaval · QA
Radhika · DevOps
💡
Core Concepts in 60 Seconds
Working Directory
→
Staging Area
→
Local Repo
→
Remote (GitHub)

Think of it as: Draft → Review Table → Your Bookshelf → Public Library

🔄
Create a New Repo from Command Line

Create a new repository on GitHub first (empty, no README), then run these commands locally:

# 1. Create project folder and enter it mkdir git-good && cd git-good # 2. Initialize Git repo git init # 3. Create README echo "# Git Good" > README.md # 4. Stage and commit git add README.md git commit -m "Initial commit" # 5. Rename branch to main (if needed) git branch -M main # 6. Add remote and push git remote add origin https://github.com/bkrajendra/git-good git push -u origin main
Exercise 1 - Quick Fire Round
10 Marks
  • Q1 What problem does Git solve that sharing ZIP files via Slack cannot? Name at least 2 problems. 2 pts
  • Q2 In the Git flow Working Dir → Staging → Local Repo → Remote, which command moves code from Staging → Local Repo? 2 pts
  • Q3 True or False: Once you git commit, the code is automatically visible on GitHub to your teammates. 2 pts
  • Q4 Isha says "I'll just email code changes to avoid Git". Give Isha 2 solid reasons why Git is better for a team of 4+. 4 pts

The Daily Git Flow

Commands your team will use 90% of the time

Scenario: Monday Morning

Dev comes in, opens his laptop, and starts coding directly on main… without pulling the latest changes. Priya had pushed a big refactor on Friday. Dev's about to have a very bad time.


The Golden Rule: Always git pull before you start working.

📋
The Essential Daily Commands
# 1. Start your day - always pull first! git pull origin main # 2. Check what files you've changed git status # 3. See what actually changed line by line git diff # 4. Stage specific files (not everything blindly!) git add src/login.js # 5. Commit with a MEANINGFUL message git commit -m "fix: validate email format on login form" # 6. Push to remote git push origin feature/login-fix
Common Issue: "My push was rejected!"

What happened: Sam pushed directly to main but got a rejection because Priya had also pushed in the meantime.


The Fix:

# Pull with rebase (cleaner history) git pull --rebase origin main # Resolve conflicts if any, then: git push origin main
Pro tip: Set git config --global pull.rebase true so rebase is always the default.
Common Issue: "I committed to main by accident!"

What happened: Tanu committed a half-finished feature directly to main instead of a feature branch.

# Undo the last commit, keep your changes staged git reset --soft HEAD~1 # Now switch to proper branch and recommit git checkout -b feature/noors-fix git commit -m "feat: add noor's new feature"
Never use git reset --hard unless you want to permanently discard changes!
Exercise 2 - Fill in the Command
10 Marks
  • Q1 Write the exact sequence of commands Dev should have used Monday morning before starting to code. 3 pts
  • Q2 What is the difference between git add . and git add src/login.js? When should you prefer each? 2 pts
  • Q3 Which commit message is GOOD? a) "fix stuff" b) "WIP" c) "fix: null pointer in user auth when email is empty" d) "changes" 2 pts
  • Q4 Noor accidentally committed to main. Write the 3-command sequence to undo and move the work to feature/noor-api. 3 pts

Branching - Your Team's Superpower

Work in parallel without stepping on each other

Scenario: Sprint Week

The Rocket team has 3 things to ship this week: Priya builds the OAuth login, Dev builds the dashboard redesign, and Sam writes the test suite.


If they all work on main - it'll be a disaster movie. With branches? Pure harmony.

🌿
Branch Naming Convention
# Feature work feature/login-oauth feature/dashboard-v2 # Bug fixes fix/null-pointer-auth fix/broken-csv-export # Experiments / spikes spike/react-18-upgrade # Hotfixes on production hotfix/payment-crash-prod
🔄
Full Branch Lifecycle
# 1. Always branch off latest main git checkout main git pull origin main git checkout -b feature/login-oauth # 2. Work, stage, commit (repeat) git add . git commit -m "feat: add google oauth integration" # 3. Push branch & open a Pull Request git push origin feature/login-oauth # 4. After PR is merged, clean up git checkout main git pull origin main git branch -d feature/login-oauth
Common Issue: "My branch is 3 weeks old!"

Dev went on a deep coding tangent. His branch is now 47 commits behind main. Merging will be painful.

# Keep your branch fresh - rebase onto main regularly git fetch origin git rebase origin/main # Fix any conflicts, then: git push --force-with-lease
Rebase at least once a day on long-running branches. Your future self will thank you.
Exercise 3 - Scenario Mapping
10 Marks
  • Q1 Write correct branch names for: (a) Sam fixing CSV export bug, (b) Priya experimenting with caching, (c) Noor doing urgent production hotfix. 3 pts
  • Q2 Write all commands to: start a new branch feature/dark-mode from main, commit "feat: add dark mode toggle", and push it. 3 pts
  • Q3 Dev's branch is 3 days old. Should he git merge main or git rebase origin/main? Explain the difference. 2 pts
  • Q4 What is the risk of git push --force vs git push --force-with-lease? 2 pts

Merge Conflicts - Don't Panic

The most feared Git moment, demystified

The Conflict Scene

Priya and Dev both edited src/utils/auth.js line 42 at the same time. Priya's version checks for a null token. Dev's version adds a new JWT decoder.


When Dev pulls and merges - Git doesn't know whose version to keep. Git leaves breadcrumbs to help you decide.

🧩
What a Conflict Looks Like
// src/utils/auth.js - Git marks the conflict: <<<<<<< HEAD ← YOUR changes (Dev) const token = jwt.decode(req.headers.token); ======= ← dividing line if (!req.headers.token) return null; const token = req.headers.token; >>>>>>> origin/main ← THEIR changes (Priya)

You need to manually edit this file to combine both intentions, then mark it resolved.

✅
Resolving the Conflict
# After manually fixing the conflict: git add src/utils/auth.js git commit -m "merge: combine jwt decode + null token check"
Use git mergetool or VS Code's built-in conflict editor for a visual way to resolve.
"I want to throw away MY changes and keep THEIRS"
# Keep incoming (their) version git checkout --theirs src/utils/auth.js # Keep your version git checkout --ours src/utils/auth.js git add src/utils/auth.js git commit -m "resolve: use upstream auth logic"
"I want to completely undo a bad merge!"
# Find the commit hash before the merge git log --oneline # Reset to before the merge (SAFE - keeps your files) git reset --merge ORIG_HEAD
Only do this BEFORE pushing. After pushing, use git revert instead - it's safer for shared branches.
Exercise 4 - Conflict Resolution
10 Marks
  • Q1 In a merge conflict block, what does HEAD represent and what does origin/main represent? 2 pts
  • Q2 Sam merges a conflict but forgets to git add the resolved file. What error will Git show? 2 pts
  • Q3 You got conflicts in 3 files after git merge feature/dark-mode. Write the step-by-step process to resolve. 3 pts
  • Q4 Why is git revert preferred over git reset --hard on shared branches? 3 pts

Team Best Practices

The unwritten rules that make great teams great

📜
The Confluxsys Team's Git Constitution
🚫
Never force-push to main or develop. It rewrites shared history and will ruin someone's day.
🚫
Avoid pushing binaries, blobs or large files. Make sure to maintain a .gitignore file.
✅
One thing per commit. Don't bundle a bug fix, refactor, and new feature together.
📝
Use Conventional Commits: feat:, fix:, docs:, chore:, refactor:, test:
🔍
Review PRs within 24 hours. Stale PRs become harder to merge over time.
🛡
Use branch protection on main. Require at least 1 reviewer. Run CI checks before merge.
🛡
Set you global username/email configuration along with git rebase
# Set global username and email git config --global user.name "Your Name" git config --global user.email "your.email@example.com" # set rebase behavior git config --global pull.rebase true
🕵
Power Commands You'll Love
# See who last changed each line (blame mode) git blame src/login.js # Search all commits for when a string was added git log -S "jwt.decode" --oneline # Stash half-done work before a context switch git stash push -m "WIP: oauth flow half done" git stash pop # bring it back # Cherry-pick a single commit onto another branch git cherry-pick a1b2c3d # See a visual branch graph git log --oneline --graph --all --decorate
"I accidentally pushed .env with secrets!"

Sam pushed a .env file with real API keys. This is a serious security incident.

# 1. Remove it from tracking immediately git rm --cached .env echo ".env" >> .gitignore git commit -m "security: remove .env from tracking" git push # 2. Rotate ALL exposed secrets IMMEDIATELY # 3. Use git-filter-repo to purge from history if needed
Set up secret scanning in GitHub. Use pre-commit hooks to block .env pushes.
Exercise 5 - Team Scenarios
10 Marks
  • Q1 Classify with Conventional Commits: (a) "Added dark mode" (b) "Typo fix in readme" (c) "Updated test for auth" (d) "Remove unused imports" 2 pts
  • Q2 Noor is mid-feature and gets a critical bug to fix. What command helps pause work safely? Write the commands. 2 pts
  • Q3 Dev needs a one-line fix from Sam's unmerged branch NOW. What command would Dev use? 2 pts
  • Q4 Priya pushed .env with DB credentials. Write the action plan: Git steps AND security actions. 4 pts

Workshop Scorecard

5 sections · 5 exercises · 30 minutes

50 Marks
0-24
Git Confused
Review fundamentals
25-34
Git Going
Solid foundation
35-44
Git Good
Team-ready
45-50
Git Wizard
Teach others!

Marks Breakdown

Exercise 1 - Why Git Exists10 marks
Exercise 2 - Daily Git Flow10 marks
Exercise 3 - Branching Superpower10 marks
Exercise 4 - Merge Conflicts10 marks
Exercise 5 - Team Best Practices10 marks

Thank You!

Now go forth and Git Good together.

git commit -m "chore: become a git master"
Slide 1 / 31