This tutorial will guide you through the process of setting up your development environment and contributing to a project on GitHub.
- Understand the basics of Git and GitHub.
- Learn how to clone a repository.
- Learn how to add changes to a repository.
- Learn how to commit changes to a repository.
- Learn how to push changes to a repository.
- Learn how to create a pull request.
- Git and Github
- Git Tutorial (w3schools.com)
- How to Use Git and GitHub – Introduction for Beginners (freecodecamp.org)
- Learn Git Branching (Interactive tutorial)
- Git - Basic Branching and Merging (git-scm.com)
- Pull Requests in VS Code - YouTube
-
Fork the repository by clicking the fork button on the top right corner of the repository page.
- Click the fork Button
This section will guide you through the process of cloning a repository, adding changes, committing changes, pushing changes, and creating a pull request.
- Open the terminal and run the following commands to configure Git:
git config --global user.name "<your-name>"
git config --global user.email "<your-email>"These commands will set your name and email for Git. This information will be used to identify you as the author of the changes you make.
Example:
git config --global user.name "John Doe"
git config --global user.email "JohnDoe@gmail.com"- Open the terminal and navigate to the directory (also known as folder) where you want to clone the repository.
- Go to the repository page on your own account and click on the green code button.
- Copy the link under the clone section.

- Run the following command inside of the opened terminal to clone the repository:
git clone <The Link from your Repository>Example:
git clone https://github.com/YOUR_NAME/Selection-Project.git-
Open the repository directory in VS Code.
- The path must be INSIDE the cloned repository.
- Click on File -> Open folder

- Select the repository folder.

- The repository should be opened in VS Code.

- To make sure, run the following command in the terminal INSIDE Vscode:
git status
-
Run the following command to add the changes:
git add .- Run the following command to commit the changes:
git commit -m "<commit-message>"- Run the following command to push the changes:
git push- Go to the repository page and click on the pull request button.

- Click on the new pull request button.

- Select the branch you want to merge into the main branch.

- Click on the create pull request button.

- Add a title and description for the pull request. Title should be in the following format:
<your-name> - <project-name>.
- Click on the create pull request button.

Usually, you will be working on a feature or a bug fix in a separate branch. This is to avoid conflicts with the main branch and to keep the main branch clean.
- Run the following command to create a new branch:
git checkout -b <branch-name>Example:
git checkout -b feature-1- Run the following command to switch to a branch:
git checkout <branch-name>Example:
git checkout main- Run the following command to merge a branch into the main branch:
git merge <branch-name>Example:
git merge feature-1This section will guide you through the process of collaborating with others on a project.
- Run the following command to add a remote repository:
git remote add <remote-name> <remote-url>Example:
git remote add origin https://github.com/Programming-Club-IAU/Level-1.1.git- Run the following command to fetch changes from a remote repository:
git fetch <remote-name>Example:
git fetch origin- Run the following command to pull changes from a remote repository:
git pull <remote-name> <branch-name>Example:
git pull origin main- Go to the repository page and click on the settings tab.
- Click on the manage access button.
- Click on the invite a collaborator button.
- Search for the username of the collaborator you want to add.
- Click on the add collaborator button.
This tutorial has covered the basics of Git and GitHub. You should now be able to clone a repository, add changes, commit changes, push changes, create a pull request, create a new branch, switch to a branch, merge branches, add a remote repository, fetch changes, pull changes, and add collaborators.







