GitHub is a web-based hosting service that allows software developers to collaborate on open-source projects easily they’re working on. Pull requests are one of the most common ways in which developers request new features or bug fixes for their project, with an average pull request taking around 10 minutes and has a success rate of about 90%. However, it’s important to understand what you’re up against before jumping into contributing your code.
GitHub is a website that allows users to contribute to open-source projects. It’s also a platform for hosting your own projects. In order to find projects to contribute to, you can use the “Find Repos” option on GitHub. Read more in detail here: how to find projects to contribute to on github.
So you’ve discovered a project on GitHub that you’d want to contribute to. How, though? You don’t consider yourself a developer, and you’re unfamiliar with source control lingo. Don’t be concerned. A Git pull request is the answer (PR).
In this lesson, you’ll learn how to use a Git pull request to contribute to a GitHub project and get your code into a GitHub repository (repo). But besides that, you should consider getting the right pipeline software that can help you track your project more easily.
GitHub Project Participation
You’ve definitely come across at least one GitHub project where you think you might help solve bugs, update documentation, or add a new feature. You want to help, but you don’t consider yourself a software developer, like many other IT professionals.
Git and GitHub have always been associated with software development. However, as more infrastructure moves to the cloud and Infrastructure as Code solutions become available, system administrators have begun examining GitHub more.
Many IT professionals are unsure where to begin. So, in this post, you’ll learn how to contribute code to an existing GitHub project via pull requests from the ground up.
What does a Pull Request entail?
Create a pull request when you have code or a repair that will improve the functionality or value of an existing project or repository on GitHub.
Although a pull request is a single action, the ultimate result (putting your code into someone else’s GitHub project) is broken down into five steps, which you’ll learn about in this article.
1. Adding the original repo to your GitHub account by forking or “copying” it.
The terms “forking” and “cloning” are often interchanged. Git and GitHub are two different services. A GitHub phrase for creating a duplicate of a GitHub project is “forking.” Cloning is a Git word for obtaining a remote Git repo and establishing a local Git repo on your machine.
2. Committing code to our cloned repository and publishing it to the GitHub repository
3. Sending the repo owner a pull request
4. The pull request is reviewed and approved by the repo owner.
5. Merging your modifications to the master branch by the repo owner
Make sure you have the following items to follow along with the examples in this tutorial:
Fork the GitHub repository
Because you can’t edit someone else’s GitHub repository directly, you must first establish your own. To do so, fork or create a clone of the repository under your own GitHub account. To do so, first:
1. Go to GitHub and log in using your chosen web browser.
2. As seen below, go to the tutorial’s repo or the repo you’d want to contribute to.
To fork a GitHub repository
3. Click the Fork button in the top-right corner. This button will generate a clone of that repository in your account automatically.
Fork a GitHub repository
You should now see the same repository in your repository list after forking. This repo was forked from Adam-the-Automatorgit-pull-requests, as you can see below.
GitHub repository forked
Adding New Code to Your Private Fork
It’s time to make your modifications now that you have your own personal copy of the repo in your GitHub account. Changes to code in a GitHub repo may be made in one of two ways: directly via github.com or locally using Git. Let’s look at both sides.
Using github.com to submit code
The web browser is the simplest method to make changes to code in a GitHub repository. You don’t have to bother about installing any software locally if you use github.com. However, if you need to make any relatively difficult modifications, utilizing the web browser will quickly become a nightmare.
Assuming you’re still using your browser to access the cloned repo:
1. In your forked repo, go to the SampleText.ps1 script and click the pencil icon to modify it.
GitHub code modification
2. Make changes to the file and, if desired, write a commit message by clicking the Commit changes button as shown below.
Using GitHub to commit changes
Using Git to Commit Code
Git should be used if you intend on making more than one basic modification to a file in the GitHub repository. You may clone the full repo to your own computer and work on it with your preferred code editor using Git.
To work on the forked repo’s code locally, you’ll need to use Git to clone the complete repository to your machine. To do so, first:
Assuming you’re still at your github.com cloned repo:
1. In the HTTPS area, click the Code button and copy the URL.
Getting the URL for the Git clone
2. Next, on your computer, open a command-line terminal. Windows PowerShell will be used in this course.
3. Create a directory in which to keep the cloned repo and execute git clone with the URL copied from the previous step as the destination.
C:Git cd md https://github.com/adbertram/git-pull-requests.git C:Git git clone
Clone a Git repository
Local File Committing and Pushing
After you’ve cloned the Git repo, edit the file and commit your changes to the repository. To do so, first:
1. Edit and save the C:SampleText.ps1 script in your preferred code editor.
2. In the terminal window, go to the C:Git directory and perform the command below. The git add command saves the file but does not add it to the local Git repo. It just starts following it.
git add SampleText.ps1 cd C:Git
3. Use the git commit command to commit or save all tracked files in the Git repo. With the -m argument, be careful to add a description of what has changed (commit message).
“changed sampletext file” git commit -m
4. Now that the local Git repo contains the changed file, push that change up to the GitHub repo with the git push command. You should receive a box asking you to to provide your GitHub username and password to authenticate to your GitHub repository forked.
5. After you’ve entered your GitHub username and password, Git should provide some status information, as seen below.
Git commits are pushed
Pull Request Submission
You now have a forked copy of the GitHub repo you’d want to contribute to in your own GitHub account, complete with the modification you’d like to propose to the original GitHub source. It’s now time to send a pull request to the owner, requesting that they accept your update.
1. Go to your cloned GitHub repository.
2. Select New pull request from the Pull Requests menu, as shown below.
Putting together a pull request
3. On the pull request page, you’ll see the two GitHub repos that will be compared, as well as each commit you want to combine into the owner’s repository. Select Create a pull request.
Making a pull request on GitHub
4. Give the pull request a title and click Create pull request.
Creating a pull request in Git
A pull request will then appear on the original GitHub repository. Your task is now complete, and you must wait for the owner.
Accepting and reviewing a Pull Request
As soon as you submit a pull request, it will appear in the original GitHub repo’s Pull Request section, as seen below.
Submit a pull request to the original GitHub repository.
The owner will now either offer you with comments or invite you to participate on the pull request. They may also integrate the pull request right away by clicking Merge pull request.
The pull request will be marked as Merged after they’ve merged it with the original code, and the code will be merged with the original repo!
Pull request merged
You may now see that you were a contributor to the file that was merged after you updated it.
Contributor to the modified file
You learnt how to generate a Git pull request step by step in this lesson. On GitHub, pull requests are an excellent method to cooperate.
What will you contribute to next now that you know how to contribute to GitHub projects?
“GitHub Projects to contribute” is a blog post that will teach you how to contribute to GitHub projects. It will also show you the steps on how to create a pull request. Reference: github projects to contribute.
- how to add contributor in github
- github contribute to open source
- github fork vs clone
- how to contribute to open source projects as a beginner
- how to contribute to open source github as a beginner