Tutorial 1: Advanced Git and Github
Mastering Git and GitHub for collaborative software development.
1. Branching Strategies
Branches let multiple developers work on the same project independently.
Common models
- Feature Branching:Each feature --> separate branch.
- GitFlow:Distinguishes between
develop, mainandreleasebranches. - Trunk-Based Development:All developers commit frequently to
mainwith feature flags.
git checkout -b feature/login-auth
git push origin feature/login-auth
2. Pull Requests & Code Reviews
- Open a Pull Request (PR) to propose merging code.
- Use PR template for consistency.
- Add reviewers, link issues, and require approval before merging.
Tip: Use "Draft Pull Requests (PRs)" for work in progress - it signals collaboration without merging prematurely.
3. Handling Merge Conflicts
When two people change the same file, Git requires manual resolution.
git pull origin main
# Fix conflicts
git add .
git commit -m "Resolve merge conflicts"
Use git diff or gh pr checkout PR number to inspect changes before merging.
4. GitHub Project Tools
- Issues:Track tasks and bugs with labels and milestones.
- Projects:Visual Kanban boards for progress tracking.
- Actions:Automate builds, tests, and deployments.
# .github/workflows/python-tests.yml
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: pytest