Welcome to our project! We're excited that you're considering contributing to open-source development. This guide will walk you through the essential Git commands and best practices to make your contribution easy and successful.
- Forking the Repository
- Cloning the Repository
- Creating a Branch
- Making Changes
- Committing Changes
- Pushing Changes
- Creating a Pull Request
- Syncing Your Fork
- Tips for Writing Good Commit Messages
Before you start contributing, you need to fork the repository. Forking creates a copy of the repository under your own GitHub account.
Steps:
- Navigate to the repository page.
- Click the "Fork" button at the top-right corner.
- You'll now have a copy of the repository in your GitHub account.
After forking the repository, you need to clone it to your local machine so you can work on it.
git clone https://github.com/your-username/repository-name.git
After cloning the repository, create a new branch to work on your changes. Always work in a separate branch to avoid conflicts with the main branch:
git checkout -b feature/your-branch-name
Now that you're in your branch, make the necessary changes to the code, documentation, or other parts of the project. Be sure to test everything before moving on to the next step.
Once your changes are complete, it's time to commit them. Follow these steps:
- Add the changes to the staging area:
git add .
- Commit the changes with a clear and descriptive message:
git commit -m "Your descriptive message here"
- Make sure your commit message clearly explains the changes you made.
After committing your changes locally, push the branch to your GitHub repository.
git push origin feature/your-branch-name
This will upload your branch to your forked repository on GitHub.
With your changes pushed to GitHub, you're ready to submit a pull request (PR) so the maintainers can review your work.
- Navigate to your forked repository on GitHub.
- Click the "Compare & pull request" button.
- Provide a title and a detailed description of your changes.
- Submit the pull request.
- After reviewing, the maintainers will either merge your PR or provide feedback for revisions.
If the original repository is updated while you're working, you might want to sync your fork to keep it up-to-date. Here's how:
- Add the upstream repository as a remote:
git remote add upstream https://github.com/original-owner/repository-name.git
- Fetch the latest changes from the upstream repository:
git fetch upstream
- Merge the upstream changes into your local main branch:
git checkout main
git merge upstream/main
- Push the updated main branch to your fork:
git push origin main
- Keep it concise: Aim for a commit message that's under 50 characters.
- Use the imperative mood: For example, write "Fix bug" instead of "Fixed bug."
- Provide context: Include the issue number or describe the purpose of the change.
Example: Fix #42 - Resolve bug in user authentication.