Thank you for contributing to ET6-foundations-group-16! π We are excited to have you on board. This document will guide you through the process of contributing to the project. Please read through the steps carefully to help us maintain high-quality code and collaboration. π©βπ»π¨βπ»
This project aims to improve the quality of software development through peer code reviews ππ. We welcome contributions that enhance the code review process, ensure coding best practices, and help maintain a clean, efficient, and well-documented codebase. πβ By participating, you help us build a better repository where developers can share feedback and improve their coding skills collaboratively. π€π‘
We believe that a strong code review process is crucial to writing clean, maintainable code and fostering a collaborative development environment. πͺ Your contribution in enhancing this process, whether through tools, documentation, or improved review guidelines, is highly valued. π
Before you begin contributing, please review these guidelines to help us maintain a consistent and high-quality codebase:
- Fork the Repository π΄: Always fork the repository before making changes. This ensures that you have a personal copy of the code to work on.
- Work in Small, Focused Branches π±: Create a new branch for each feature, bug fix, or improvement. Name your branch descriptively based on what you're working on.
- Write Clear Commit Messages βοΈ: Make your commit messages concise and descriptive. For example, instead of "Fix bug", use "Fix issue with divide by zero."
- Test Your Code π§ͺ: Ensure that your code is tested and works as expected. If you're adding features, write appropriate tests to verify functionality.
- Keep Pull Requests Small π: Focus on one task per pull request. This makes it easier to review and reduces the likelihood of conflicts.
- Respect the Code of Conduct π€: Follow our community's code of conduct and behave respectfully in all interactions.
We are committed to maintaining a collaborative and inclusive environment, and your contribution will play a vital role in the project's success. ππΌ With that in mind, let's dive into the steps for contributing! π
- Install Git on your local machine (https://git-scm.com/downloads)
- Install Visual Studio Code (https://code.visualstudio.com/)
- Create a GitHub account if you don't have one
-
Open Terminal (Mac/Linux) or Git Bash (Windows)
-
Generate an SSH key:
ssh-keygen -t ed25519 -C "[email protected]"
-
Start the SSH agent:
eval "$(ssh-agent -s)"
-
Add your SSH key to the agent:
ssh-add ~/.ssh/id_ed25519
-
Copy your public key:
cat ~/.ssh/id_ed25519.pub
-
Add the key to your GitHub account:
- Go to GitHub Settings β SSH and GPG keys
- Click "New SSH key"
- Paste your public key and save
git clone [email protected]:username/repository.git
git clone https://github.com/username/repository.git
-
Navigate to the project directory:
cd repository-name
-
Configure your Git identity:
git config --global user.name "Your Name" git config --global user.email "[email protected]"
-
Open the project in VS Code:
code .
- Create or modify a file in your repository
- Stage your changes:
For single file change:
git add <file name>
For all changes in severals files:
git add .
-
Commit your changes:
git commit -m "Initial commit: Add project setup files"
-
Push to the main branch:
For the main branch:
git push origin main
For certain branch:
git push origin <branch_name>
- If you encounter permission denied errors, verify your SSH key is properly added to GitHub
- For SSL certificate issues, ensure your Git installation is up to date
- If VS Code doesn't recognize Git, restart VS Code after Git installation
Head over to your forked repository on GitHub, where your code changes are waiting to shine.
HOW?
- Go to your forked repository on GitHub.
- Switch to the branch where you made your changes.
Spot the "Compare & pull request" button? Give it a click to start the magic.
HOW?
- Select "New Pull Request."
- Compare your branch to the base branch of the original repository.
- π¨ Title: Craft a catchy yet informative title for your pull request.
- π Description: Paint a picture of your changes. Explain what you did, why it matters, and any issues it resolves (e.g., "Fixes #42").
- π Link Issues: Connect your PR to relevant issues by mentioning them.
- π΅οΈββοΈ Choose Your Reviewers: Select team members to review your masterpiece. This can be done in the right sidebar under "Reviewers."
- π·οΈ Label It: Use labels to categorize your pull request (e.g., "bug", "enhancement", "documentation").
- π§ Inspect the Code: Dive into the code changes. Ensure they follow the project's style and guidelines.
- π§ͺ Experiment: Pull the branch locally and test the changes. Make sure everything works like a charm.
- π¬ Comment Constructively: Use inline comments to suggest improvements or ask questions. Remember, feedback is a gift!
- β Approve: If everything looks great, give it your seal of approval.
- π Request Changes: If tweaks are needed, request changes and provide clear instructions.
- βοΈ Check the Checks: Make sure all automated tests and checks are green-lit before merging.
- π Seal the Deal: Click the "Merge pull request" button and confirm the merge.
- π§Ή Choose Your Method: Opt for "Squash and merge" for a tidy commit history.
- ποΈ Clean Up: After merging, delete the branch to keep the repository neat and organized.
- Click "Convert to draft" when your PR needs more work.
- When Ready for Review: Click "Ready for review" when the PR is complete and ready for review.
- Good Draft PR Title: π [WIP] Add user authentication system
- Title: "Add login form validation"
- Changes: 3-5 files
- Lines of Code: ~200 lines
- Feature Focus: Single, focused feature
-
Title: "Update entire user system"
-
Changes: 20+ files
-
Lines of Code: 1000+ lines
-
Feature Focus: Multiple features mixed
If you encounter merge conflicts while merging a PR:
-
Checkout Your Branch
git checkout your-branch
-
Pull Latest Changes from Main
git pull origin main
-
Resolve Conflicts
Open the conflicting files in your code editor (e.g., VS Code) and manually resolve the conflicts.
-
Stage the Changes
git add .
-
Commit the Resolution
git commit -m "Resolve merge conflicts with main"
-
Push the Resolved Changes
git push
After pushing, GitHub will automatically update the PR with the resolved conflicts.
Collaboration is key to successful teamwork, and following best practice helps heep everything running smoothly. Below are some important practices to follow, complete with examples to ensure effective collaboration:
Commit messages should clearly describe what changes have been made and why. A well-written commit message helps other developers understand the purpose of the change and make it easier to navigate the project's history.
Best Practice for Commit Messages: βοΈ
- Be clear and concise: Briefly describe what was changed and why.
- Follow a consistent format: This makes it easier to read and understand.
- Use the imperative mood: Write messages as commands (e.g "Fix bug" instead of "Fixed bug").
Examples:
- Good Commit Message:
git commit -m "Fix bug in user login validation"
Explanation: This message clearly explains that a bug in the validation has been fixed, which helps others understand the purpose of the change.
- Bad Commit Message:
git commit -m "Fixed login"
Explanation: This message is vague and doesn't explain what part of the login process was fixed or why. Why this important: Clear commit messages make it easier for your team to understand changes without needing to dive into the code, and they make reviewing and tracking changes much easier.
Use a structured branching strategy ensures the team works in an organized manner. Each new task should be worked on in its won branch, which keeps the main codebase clean and makes collaboration easier. Best Practices for Branching:
-
Create a branch for each task: Each feature, bug fix, or improvement should have its own branch.
-
Name branches descriptively: Use branch names that reflect the task you're working on.
Examples:
- Feature Branch:
git checkout -b feature/login-page
Explanation: You're creating a branch specifically to work on the login page feature
- Bug Fixe Branch:
git checkout -b bugfix/fic-header-alignment
Explanation: This branch is dedicated to fixing an issue with the header alignment.
- Hotfix Branch:
git checkout -b hotfix/fix-crash-on-startup
Explanation: A hotfix branch is used to add a critical issue, such as a when starting the application.
Why this is important: By creating separate branches for each task and naming them descriptively, the team can work on multiple tasks at once without interfering with each other's work. It also makes it easy to track what each branch is working on.
Merge conflicts occur when two or more team members changes to the same part of a file. You need to resolve these conflicts manually to make sure that all changes are merged correctly.
Steps for Resolving Merge Conflicts:
Understanding Merge Conflicts When there's a conflict, Git will mark the conflicting areas in the file. These markers indicate the changes made by both you and the other developer.
Imagine two developers are working on the Markdown file README.md
or
python file Calculation.py
for example, in Markdown file:
<<<<<<< HEAD
# How to Contribute
This guide will help you contributing effectively.
=======
# How to Contribute
This document explains the best practices for contributing to the project.
>>>>>>> fearuer/section-1
In this case, the conflict is in the header(# How to contribute
), and
both versions contain different text following the heading.
Similarly, in a Python file, a conflict could look like this:
<<<<<<< HEAD
def greeting():
print("Welcome to the project!")
=======
def greeting():
print("Hello, thanks for contributing!")
>>>>>>> fearuer/greeting
Steps for resolving conflicts in Markdown or Python files:
- Step 1: Identify the Conflict π΅οΈββοΈ
- Look for the conflict markers. You will see:
-
<<<<<<< HEAD
: The changes you made. -
=======
: The division between your changes and the incoming changes. -
>>>>>>> branch-name
: the changes made by someone else (in the specified branch)
-
Example (Markdown conflict):
<<<<<<< HEAD
# How to Contribute
This guide will help you contribute effectively
=======
# How to Contribute
This document explains the best practices for contributing to the project.
>>>>>>> feature/section-1
-
Step 2: Decide which changes to keep βοΈ
- You need to decide if you want to keep your changes, the other personβs changes, or merge both sets of changes.
In the Markdown file, you might want to combine both sentences:
# How to Contribute
This guide will help you contribute effectively and explains the best practices
for contributing to the project.
In the Python file, you could keep both greetings or choose one:
def greeting():
print("Welcome to the project!")
# Or, combine both greetings:
# print("Hello, thanks for contributing!")
-
Step 3: Remove Conflict Markers π§Ή
- After deciding, delete the conflict marker(
<<<<<<
,======
, and>>>>>>
). For instance, in Markdown:
- After deciding, delete the conflict marker(
# How to Contribute
This guide will help you contribute effectively and explains the best practices
for contributing to the project.
By following these steps, you'll resolve conflicts easily, whether you'er working on a Markdown file or a Python file. The key is to understand the changes, merge them carefully, and test everything before committing your changes.
We are excited to have your contribution to improve the repository and help us build better software together! πͺ