Session 12 Git 2025-2026 1º
Git in a Team: Branches, Conflicts and Pull Requests
Collaborative Git workflow applied to the club project: branches, conflict resolution, and team conventions.
Key Concepts
- Branches: what they are and why they matter
- Team workflow: protected
mainand feature branches - Pull requests: opening, reviewing, and merging
- Merge conflicts: why they happen and how to resolve them
- Commit conventions: clear and consistent messages
Mandatory Part
1. Quick recap: current repository state
Check the project status before starting:
git status
git log --oneline --graph --all
Make sure all members have the repository up to date:
git pull origin main
2. Create a working branch
Each member creates their own branch to work on an improvement or fix:
git checkout -b feature/improvement-name
Make at least one real change to the code, stage it, and commit:
git add .
git commit -m "feat: brief description of the change"
3. Commit conventions
Use the following format for all project commits:
type: short description in imperative mood
Common types:
feat → new feature
fix → bug fix
refactor → code improvement without changing behavior
docs → documentation changes
test → adding or modifying tests
Correct examples:
feat: add grade validation to Student
fix: fix average calculation when list is empty
refactor: extract statistics logic to GradeCalculator
4. Push the branch and open a pull request
Push the branch to the remote repository:
git push origin feature/improvement-name
Open a pull request on GitHub/GitLab with:
- A descriptive title
- A brief description of what changes and why
- Request a review from another member
5. Resolve a merge conflict
Prepared scenario: two members have modified the same file on the same line.
When trying to merge, Git detects the conflict:
<<<<<<< HEAD
return self.grade >= 5
=======
return self.grade > 4.9
>>>>>>> feature/other-branch
Steps to resolve it:
- Open the file and decide which version stays (or combine both)
- Remove the conflict markers
- Stage the resolved file and commit:
git add conflicted_file.py
git commit -m "fix: resolve conflict in is_passing method"
Extended Part
6. Define the project workflow
Agree as a team on the workflow for the remaining sessions:
- How are branches named?
- Who reviews pull requests?
- What must a PR fulfill before it can be merged?
Document it in the project README.