Apply Git knowledge to realistic development situations
Practice Git with realistic scenarios you'll encounter in professional development.
These scenarios simulate real-world development situations you're likely to encounter. Each scenario combines multiple Git concepts and requires careful planning and execution.
Your team is preparing a major release that includes three features. Two are complete, but one needs more testing. Meanwhile, a critical bug is reported in production that needs immediate attention.
auth.js
$ git add auth.js && git commit -m "Implement user authentication"
$ git checkout develop $ git checkout -b feature/payment-api $ echo "Payment API" > payment.js $ git add payment.js && git commit -m "Implement payment API"
$ git checkout develop $ git checkout -b feature/reporting $ echo "Reports" > reports.js $ git add reports.js && git commit -m "Add reporting feature"`} />
- Create a release branch for the complete features
- Handle the critical bug fix
- Merge completed features while keeping reporting separate
- Update all branches with the bug fix
fix.js
$ git add fix.js $ git commit -m "Fix critical production issue"
$ git checkout main $ git merge hotfix/critical-bug $ git tag -a v1.0.1 -m "Hotfix release"
$ git checkout develop $ git merge hotfix/critical-bug $ git checkout release/v2.0 $ git merge hotfix/critical-bug
$ git checkout main $ git merge release/v2.0 $ git tag -a v2.0 -m "Major release with auth and payments"`} />
Multiple team members have been working on related features that affect the same configuration files. You need to merge all changes while ensuring the configuration remains valid.
config.json
A team member accidentally force-pushed an old version of the develop branch, losing several important commits. You need to recover the lost work and establish safeguards.
- Configure branch protection rules
- Set up automated backups
- Document recovery procedures
- Always create backup branches before complex operations
- Communicate with team members before major branch operations
- Maintain a clear branching strategy and document exceptions
- Set up automated testing for critical configuration files