Welcome to the world of open-source contribution! This guide will walk you through the process of making your first pull request. Let's get started! π
- π Open Source Contribution Guide
- π Table of Contents
- π οΈ Installing Git on Windows 11 & macOS
- π§βπ» Setting up VSCode
- π Configuring SSH Key to Upload from Your PC or VSCode
- π Understanding Basic Git Commands
- π Contributing via GitHub (in-browser)
- π» Contributing Locally
- π Resolving Merge Conflicts
- π€ Community Guidelines
- π Additional Resources
- Download Git: Head to Git for Windows and download the installer.
- Install Git:
- Run the
.exefile you downloaded. - Follow the setup wizard, leaving the default settings as is (recommended).
- Make sure to select the option to use Git from the command line and third-party software.
- Run the
- Verify Installation:
- Open Command Prompt or PowerShell.
- Type
git --versionto ensure Git is installed correctly.
- Using Homebrew:
- If you have Homebrew installed, open the Terminal and run:
brew install git
- Without Homebrew:
- Download Git from git-scm.com.
- Open the
.dmgfile and follow the instructions.
- Verify Installation:
- Open the Terminal.
- Type
git --versionto confirm Git is installed.
-
Download VSCode:
- Go to Visual Studio Code and download the appropriate installer for your system (Windows, macOS).
-
Install the Git Extension:
- Open VSCode and navigate to the Extensions tab (left sidebar).
- Search for
GitLensand install it to enhance Git functionality within VSCode.
-
Configure Git in VSCode:
- Open VSCode and press
Ctrl + ~to launch the integrated terminal. - Set up your Git username and email:
git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
- Open VSCode and press
-
Verify Git in VSCode:
- Run
git --versionin the terminal to check everything is configured correctly.
- Run
Before you can securely upload files from your PC or VSCode to GitHub, you'll need to generate an SSH key. Follow these steps based on your operating system.
-
Open Git Bash (installed with Git).
-
Run the following command to generate a new SSH key:
ssh-keygen -t ed25519 -C "your_email@example.com"- If you are using a legacy system that doesn't support Ed25519, use:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -
Press
Enterto accept the default file location, and if prompted, enter a passphrase for additional security (you can leave this blank).
-
Open Terminal.
-
Use the same command to generate an SSH key:
ssh-keygen -t ed25519 -C "your_email@example.com" -
Press
Enterto save the SSH key to the default location and set a passphrase if desired.
You need to add your SSH private key to the SSH agent, which manages your keys.
-
In Git Bash, start the SSH agent:
eval "$(ssh-agent -s)"
-
Add your SSH key to the agent:
ssh-add ~/.ssh/id_ed25519
-
In Terminal, start the SSH agent:
eval "$(ssh-agent -s)"
-
Add your SSH key:
ssh-add -K ~/.ssh/id_ed25519
Now, you need to find your SSH public key and copy it to add it to GitHub.
- Display the public key by running:
cat ~/.ssh/id_ed25519.pub - Copy the entire output, which will look something like this:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA2v2p2O... your_email@example.com
Now that you have your SSH key, add it to your GitHub account to enable secure uploads.
- Go to GitHub and log in to your account.
- In the upper-right corner of any page, click your profile photo, then click Settings.
- In the left sidebar, click SSH and GPG keys.
- Click New SSH key.
- In the "Title" field, add a descriptive label for the new key (e.g., "My PC SSH Key").
- Paste your SSH public key into the "Key" field.
- Click Add SSH key.
To make sure your SSH key is correctly configured, test the connection:
-
In Git Bash (Windows) or Terminal (macOS), type:
ssh -T git@github.com
-
If everything is set up correctly, you should see a message like:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
Now that the SSH key is set up, you need to configure Git to use SSH for pushing to GitHub.
-
Set Git to use SSH by running:
git remote set-url origin git@github.com:USERNAME/REPO-NAME.git
-
Push your changes as you normally would:
git add . git commit -m "Your commit message" git push origin branch-name
If youβre using VSCode, you can push changes using the Source Control tab:
- Stage your changes: Click the plus icon next to the files or folders you modified.
- Write a commit message and hit the checkmark icon to commit your changes.
- Push to GitHub: Click the three dots (ellipsis) at the top of the Source Control tab and select
Push.
Your files will now be securely pushed to your GitHub repository using your SSH key!
Here are some essential Git commands you'll be using:
flowchart LR
A[git init] -->|Initialize| B[git clone]
B -->|Copy| C[git add]
C -->|Stage| D[git commit]
D -->|Save| E[git push]
E -->|Upload| F[git pull]
F -->|Download| G[git branch]
G -->|Manage| H[git checkout]
git init: π Initialize a new Git repository.git clone: π₯ Copy a remote repository to your local machine.git add: β Stage changes for the next commit.git commit: πΎ Save the changes you've staged.git push: π Upload your local commits to the remote repository.git pull: π Download and integrate changes from the remote repository.git branch: πΏ List, create, or delete branches.git checkout: π Switch between different branches.
flowchart LR
Fork[Fork the project]-->branch[Create a New Branch]
branch-->Edit[Edit file]
Edit-->commit[Commit the changes]
commit -->|Finally|creatpr((Create a Pull Request))
- Click the
Forkbutton at the top right of the project page to create your own copy.
- On your forked repository page, click the
mainbranch dropdown. - Enter a name for your new branch (e.g., "add-my-name") and select "Create branch."
- Navigate to the
README.mdfile, and click the pencil icon to make edits. - Add your name and GitHub profile link in alphabetical order.
- Go to the "Pull requests" tab in your forked repo.
- Click
New pull request, add a title and description for your PR, and submit!
flowchart LR
A[Fork Repository] --> B[Clone to Local Machine]
B --> C[Create New Branch]
C --> D[Make Changes]
D --> E[Commit Changes]
E --> F[Push to GitHub]
F --> G[Create Pull Request]
- Click
Forkon the project page to create your own copy.
git clone https://github.com/YOUR-USERNAME/REPO-NAME.git
cd REPO-NAMEgit checkout -b branch-name- Open the file you want to edit and make your changes.
git add .
git commit -m "Add YOUR-NAME to contributors"git push origin branch-name- Go to your forked repository, click on "Pull requests," and create a new PR!
If you encounter a merge conflict, follow these steps:
flowchart LR
A[Pull latest changes] --> B[Identify conflicts]
B --> C[Resolve conflicts manually]
C --> D[Stage resolved files]
D --> E[Commit changes]
E --> F[Push updates]
F --> G[Update Pull Request]
- Pull the latest changes from the upstream repository:
git pull upstream main- Resolve conflicts manually in your code editor.
- Stage the resolved files:
git add .- Commit the changes:
git commit -m "Resolved merge conflicts"- Push the changes to your fork:
git push origin your-branch-nameWe are committed to providing a welcoming and inclusive experience for all contributors. Please be respectful and follow our code of conduct when participating.
pie title Community Values
"Respect" : 30
"Inclusivity" : 25
"Collaboration" : 20
"Open Communication" : 15
"Continuous Learning" : 10
- π Pro Git Book
- π GitHub Guides
Remember, every expert was once a beginner. Don't hesitate to ask questions and learn from your mistakes.
Happy Contributing! π