Git & GitHub

Git & GitHub in Professional Development

13 min Lesson 35 of 35

Git & GitHub in Professional Development

Welcome to the final lesson! In this comprehensive capstone, we'll walk through complete real-world scenarios that demonstrate how Git and GitHub are used in professional software development. You'll see how everything you've learned comes together in practice.

Complete Project Workflow Walkthrough

Let's follow a project from inception to production deployment:

Phase 1: Project Initialization # Create new repository on GitHub 1. Click "New repository" 2. Name: company-dashboard 3. Add README, .gitignore (Node), MIT License 4. Create repository # Clone locally git clone git@github.com:company/company-dashboard.git cd company-dashboard # Set up project structure npm init -y npm install express react typescript # Initial commit git add . git commit -m "chore: initialize project with dependencies" git push origin main # Set up branch protection - Enable branch protection on main - Require 1 approval - Require status checks (tests, lint) - Enable "Require branches to be up to date"
Key Point: Always start with a solid foundation: proper repository structure, protection rules, and CI/CD before writing features.

Starting a New Feature

A product manager creates an issue for a new user dashboard feature:

Issue #42: Implement User Dashboard Description: Users need a dashboard to view their activity Acceptance Criteria: - Display user statistics - Show recent activity feed - Implement responsive design - Add loading states # Assign yourself and start working 1. Assign issue to yourself 2. Add label: "feature", "frontend" 3. Add to project board: "In Progress" # Create feature branch git checkout main git pull origin main git checkout -b feature/USER-42-user-dashboard # Start development # Make changes to src/components/Dashboard.tsx git add src/components/Dashboard.tsx git commit -m "feat(dashboard): add user statistics component - Display total projects, tasks, and team members - Implement card-based layout - Add loading skeleton Refs #42" # Continue development with multiple commits git commit -m "feat(dashboard): add activity feed component" git commit -m "feat(dashboard): implement responsive grid layout" git commit -m "test(dashboard): add component tests" git commit -m "docs(dashboard): update README with dashboard usage"
Pro Tip: Reference issues in commits using "Refs #42". Use "Closes #42" in the final PR to auto-close the issue when merged.

Daily Development Routine

Here's what a typical development day looks like:

Morning Routine (9:00 AM): # Check notifications gh api notifications # Update main branch git checkout main git pull origin main # Return to feature branch and sync git checkout feature/USER-42-user-dashboard git merge main # Or: git rebase main # Review code review requests gh pr list --search "review-requested:@me" gh pr view 45 gh pr review 45 --approve -b "LGTM! Great work on the error handling" Mid-day (2:00 PM): # Continue development git add . git commit -m "feat(dashboard): add data refresh functionality" # Push to backup work git push origin feature/USER-42-user-dashboard End of day (5:30 PM): # Commit any work in progress git add . git commit -m "wip: working on chart integration" # Push to remote git push origin feature/USER-42-user-dashboard # Check tomorrow's tasks gh issue list --assignee @me

Collaborating with Teammates

Real collaboration scenarios you'll encounter:

Scenario 1: Merge Conflict # You and colleague both modified user service git pull origin main # CONFLICT in src/services/userService.ts # Open the file and resolve <<<<<<< HEAD async function getUser(id: string) { return api.get(`/users/${id}`); ======= async function fetchUser(userId: string) { return axios.get(`/api/users/${userId}`); >>>>>>> feature/USER-42-user-dashboard # Resolved version (discuss with teammate first!) async function getUser(userId: string) { return api.get(`/users/${userId}`); } # Mark as resolved git add src/services/userService.ts git commit -m "fix: resolve merge conflict in userService Kept function name getUser but adopted userId parameter name and api client from main branch" Scenario 2: Code Review Feedback # Reviewer comments: "Please extract magic numbers to constants" # Make changes git add . git commit -m "refactor(dashboard): extract magic numbers to constants" git push # Reviewer: "Add error handling for API failures" git add . git commit -m "feat(dashboard): add error handling and retry logic" git push # Before final merge, clean up commits git rebase -i main # Squash "refactor" and "feat" commits into main feature commits git push --force-with-lease
Important: Always communicate before resolving conflicts. Don't assume your version is correct. Discuss with the other developer.

Creating a Pull Request

Your feature is complete and ready for review:

# Before creating PR, prepare your branch git checkout feature/USER-42-user-dashboard # 1. Ensure branch is up to date git fetch origin main git rebase origin/main # 2. Run all checks locally npm run lint npm run test npm run build # 3. Review your own changes git diff origin/main...HEAD # 4. Clean up commit history git rebase -i origin/main # Squash fixup commits, reword unclear messages # 5. Force push clean history git push --force-with-lease # 6. Create pull request gh pr create --title "feat: implement user dashboard" \ --body "$(cat <<EOF ## Description Implements the user dashboard feature requested in #42 ## Changes - Added Dashboard component with user statistics - Implemented activity feed with real-time updates - Added responsive grid layout for mobile - Included loading states and error handling - Added comprehensive test coverage (95%) ## Screenshots ![Dashboard Desktop](./screenshots/dashboard-desktop.png) ![Dashboard Mobile](./screenshots/dashboard-mobile.png) ## Testing - [x] Tested on Chrome, Firefox, Safari - [x] Tested responsive breakpoints - [x] Tested with mock data - [x] Tested error scenarios ## Checklist - [x] Tests pass - [x] Documentation updated - [x] No console errors - [x] Follows style guide Closes #42 EOF )"

Your PR is created! Now wait for CI and reviews:

# Monitor PR status gh pr view 50 # CI runs automatically ✓ Tests passed ✓ Linting passed ✓ Build succeeded ✓ Coverage threshold met (95% > 80%) # Reviewers are automatically assigned via CODEOWNERS # @frontend-team and @jane-doe requested # Address review comments # Jane comments: "Consider adding loading skeleton" git checkout feature/USER-42-user-dashboard # Make changes git add . git commit -m "feat(dashboard): add loading skeleton component" git push # After approval gh pr merge 50 --squash --delete-branch

Release Management

Preparing and deploying a new version:

Creating a Release: # Update version in package.json npm version minor # 1.2.0 → 1.3.0 # This creates a git tag automatically # Update CHANGELOG.md ## [1.3.0] - 2024-01-15 ### Added - User dashboard with statistics and activity feed (#42) - Real-time notifications system (#43) - Dark mode support (#44) ### Fixed - Memory leak in chart component (#45) - Authentication timeout issue (#46) ### Changed - Improved performance of data fetching (30% faster) # Commit changelog git add CHANGELOG.md package.json git commit -m "chore: bump version to 1.3.0" git push # Push tag git push origin v1.3.0 # Create GitHub release gh release create v1.3.0 \ --title "Version 1.3.0 - Dashboard Feature" \ --notes "$(cat CHANGELOG.md | sed -n '/## \[1.3.0\]/,/## \[/p')" \ --latest # Build and attach release artifacts npm run build gh release upload v1.3.0 dist/app.zip # Deployment happens automatically via GitHub Actions # Monitor deployment gh run list --workflow=deploy gh run watch
Best Practice: Use semantic versioning (MAJOR.MINOR.PATCH) and maintain a detailed CHANGELOG.md for every release.

Hotfix Workflow

A critical bug is discovered in production:

Emergency: Users can't log in! # 1. Immediately create hotfix branch from production tag git checkout -b hotfix/login-critical-bug v1.3.0 # 2. Identify and fix the issue quickly # Bug found: authentication token expiry check is broken git add src/auth/tokenService.ts git commit -m "fix: correct token expiry validation logic The expiry check was comparing timestamps incorrectly, causing valid tokens to be rejected. BREAKING ISSUE: Users unable to log in since v1.3.0 deployment IMPACT: All users SEVERITY: Critical" # 3. Test the fix locally npm run test:auth npm run test:e2e # 4. Create emergency PR gh pr create --title "HOTFIX: Fix critical login bug" \ --body "Critical fix for production login issue" \ --label "hotfix,critical" \ --reviewer @senior-dev \ --base main # 5. Get expedited review and merge # Senior dev reviews within 15 minutes gh pr merge 51 --squash # 6. Immediately create hotfix release git checkout main git pull npm version patch # 1.3.0 → 1.3.1 git push git push origin v1.3.1 gh release create v1.3.1 \ --title "Version 1.3.1 - Critical Login Fix" \ --notes "## Critical Hotfix\n\nFixed authentication bug preventing user logins" \ --latest # 7. Monitor deployment gh run watch # 8. Verify fix in production curl https://api.company.com/health # Status: OK # 9. Communicate to team # Post in Slack: "Hotfix deployed, login restored"
Critical: For hotfixes, speed is essential but don't skip testing. A bad hotfix can make things worse. Always have a senior developer review.

Emergency Rollback Scenarios

When a deployment goes wrong:

Scenario: v1.3.0 deployment causing errors # Option 1: Revert the problematic commit git revert <bad-commit-hash> git push # Triggers new deployment automatically # Option 2: Rollback to previous release git checkout v1.2.0 git checkout -b rollback/to-v1.2.0 git push origin rollback/to-v1.2.0 # Create immediate PR gh pr create --title "Rollback to v1.2.0" \ --body "Emergency rollback due to critical errors in v1.3.0" \ --label "rollback,critical" # Option 3: If using tags for deployment # Redeploy previous version git tag -f production v1.2.0 git push origin production --force # Option 4: Use GitHub deployments API gh api repos/company/dashboard/deployments \ -f ref=v1.2.0 \ -f environment=production \ -f description="Emergency rollback" # After rollback 1. Monitor error rates 2. Analyze what went wrong 3. Create issue with incident report 4. Fix in new branch 5. Deploy fix when ready

Integrating with CI/CD

Professional workflow with continuous integration:

# .github/workflows/ci.yml name: Continuous Integration on: pull_request: branches: [main] push: branches: [main] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: '18' - run: npm ci - run: npm run lint - run: npm run test - run: npm run build security: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Run security audit run: npm audit --audit-level=moderate deploy-staging: needs: [test, security] if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Deploy to staging run: ./scripts/deploy-staging.sh env: DEPLOY_KEY: ${{ secrets.STAGING_DEPLOY_KEY }}

Common Pitfalls and Solutions

Learn from common mistakes:

Pitfall 1: Committing secrets ❌ git add .env ✓ Add .env to .gitignore ✓ Use environment variables ✓ Store secrets in GitHub Secrets Pitfall 2: Large commits ❌ git commit -m "Friday changes" ✓ Make small, focused commits ✓ Commit after each logical change Pitfall 3: Force pushing to shared branches ❌ git push --force origin main ✓ Never force push to main/protected branches ✓ Use --force-with-lease on feature branches ✓ Communicate before force pushing Pitfall 4: Not pulling before pushing ❌ Make changes, push, get rejected ✓ Always pull before starting work ✓ Regularly sync with main during development Pitfall 5: Unclear commit messages ❌ "fix stuff", "update", "temp" ✓ "fix(auth): correct token validation logic" ✓ Follow conventional commits format Pitfall 6: Not reviewing your own PR ❌ Create PR immediately after last commit ✓ Review your changes first ✓ Test all scenarios locally ✓ Clean up commit history

Career Skills: Git in Job Interviews

Git knowledge that impresses interviewers:

Common Interview Questions: Q: "Explain git rebase vs git merge" A: Merge creates a merge commit preserving history. Rebase rewrites history, creating linear history. Use rebase for feature branches before PR. Use merge for incorporating approved PRs. Q: "You accidentally committed a password. What do you do?" A: 1. Immediately rotate the password 2. Remove from history with git filter-branch or BFG 3. Force push (coordinate with team) 4. Add to .gitignore to prevent recurrence Q: "How do you resolve a merge conflict?" A: 1. Identify conflicting files (git status) 2. Open files, look for conflict markers 3. Discuss with teammate if needed 4. Choose correct version or combine changes 5. Remove conflict markers 6. git add, then git commit 7. Test thoroughly Q: "Explain your team's Git workflow" A: Describe Git Flow or GitHub Flow Explain branch naming conventions Describe PR and review process Mention CI/CD integration Q: "How do you keep your branch updated?" A: Regularly merge or rebase main into feature branch Before creating PR, ensure branch is current Resolve conflicts incrementally, not all at end
Interview Tip: Don't just memorize commands. Explain WHY you use certain workflows and HOW they benefit the team. Show you understand collaboration, not just Git.

Continuing Education Resources

Keep improving your Git and GitHub skills:

Official Documentation: - Git Documentation: git-scm.com/doc - GitHub Docs: docs.github.com - Git Book (free): git-scm.com/book Interactive Learning: - Learn Git Branching: learngitbranching.js.org - GitHub Skills: skills.github.com - Git Immersion: gitimmersion.com Advanced Topics: - Pro Git Book (advanced chapters) - Git internals and plumbing commands - Git hooks and automation - Large repository management - Git LFS and large files Practice Projects: - Contribute to open source - Set up complex workflows - Experiment with Git features - Help teammates with Git issues - Document your team's Git practices Community: - Stack Overflow git tag - GitHub Community Forum - Git mailing list - Local Git meetups

Professional Git Checklist

Master these skills for professional development:

Essential Skills (Must Know): ☑ Create and clone repositories ☑ Make commits with clear messages ☑ Create and merge branches ☑ Resolve merge conflicts ☑ Push and pull changes ☑ Create pull requests ☑ Review code effectively ☑ Use .gitignore properly ☑ Understand basic Git Flow Intermediate Skills (Should Know): ☑ Interactive rebase (squash, reword) ☑ Cherry-pick commits ☑ Use git stash effectively ☑ Recover deleted branches with reflog ☑ Set up branch protection ☑ Configure CODEOWNERS ☑ Write GitHub Actions workflows ☑ Use git bisect for debugging ☑ Understand git internals Advanced Skills (Nice to Have): ☑ Optimize large repositories ☑ Use Git LFS for large files ☑ Write custom Git hooks ☑ Debug with git reflog and fsck ☑ Manage complex merge scenarios ☑ Set up Git servers ☑ Automate Git workflows ☑ Contribute to Git development

Capstone Project:

Complete Professional Workflow Simulation:

  1. Create a new repository with full setup (README, .gitignore, CONTRIBUTING.md, branch protection)
  2. Create an issue for a feature you want to build
  3. Create a feature branch and make 5+ commits following conventional commits
  4. Create another branch simulating a teammate's work that will conflict
  5. Merge both branches and resolve the conflict
  6. Create a pull request with comprehensive description
  7. Set up GitHub Actions for automated testing
  8. Simulate code review feedback and address comments
  9. Merge the PR and create a release with semantic versioning
  10. Create a hotfix branch for an emergency bug
  11. Document your entire workflow in a WORKFLOW.md file

Final Summary

Congratulations on completing this comprehensive Git & GitHub tutorial! Let's recap everything you've learned:

Module 1: Version Control Fundamentals ✓ Understanding version control systems ✓ Installing and configuring Git ✓ Git architecture and data model ✓ Basic Git workflow Module 2: Core Git Commands ✓ Tracking changes and making commits ✓ Viewing history and diffs ✓ Undoing changes safely ✓ Working with branches ✓ Merging and rebasing Module 3: Remote Repositories ✓ Understanding remotes ✓ Pushing and pulling changes ✓ Cloning repositories ✓ Working with tags ✓ Stashing changes Module 4: GitHub Fundamentals ✓ GitHub platform features ✓ Creating repositories ✓ Managing issues ✓ Pull requests and code review ✓ Forking and contributing ✓ GitHub Actions basics Module 5: Collaboration Workflows ✓ Git Flow, GitHub Flow, Trunk-Based Development ✓ Code review best practices ✓ Resolving merge conflicts ✓ Team collaboration strategies Module 6: Advanced Topics ✓ Git hooks and automation ✓ Advanced Git commands ✓ Git internals and troubleshooting ✓ Best practices and security ✓ GitHub advanced features ✓ Team collaboration setup Module 7: Professional Development ✓ Complete project workflows ✓ Daily development routine ✓ Release management ✓ Hotfix and rollback procedures ✓ CI/CD integration ✓ Career skills and continuing education

Your Git & GitHub Journey

You've now mastered Git and GitHub from beginner to professional level. Here's what you can do next:

Immediate Actions: 1. Apply these skills in your current projects 2. Set up proper Git workflows for your team 3. Contribute to open source projects 4. Help others learn Git 5. Document your team's Git practices Long-term Growth: - Explore advanced Git internals - Master complex workflow scenarios - Automate repetitive Git tasks - Contribute to Git or GitHub development - Become your team's Git expert Share Your Knowledge: - Mentor junior developers - Write blog posts about Git - Create Git tutorials - Speak at meetups about Git workflows - Contribute to Git documentation
Remember: Git mastery comes with practice. Don't be afraid to experiment in test repositories. Everyone makes mistakes with Git—the key is learning how to recover from them. Keep this tutorial as a reference and revisit sections as needed. Happy coding!

Thank you for completing this comprehensive Git & GitHub tutorial. You're now equipped with professional-level version control skills. Go build amazing things!

Tutorial Complete!

Congratulations! You have completed all lessons in this tutorial.