How to create a PR to edit a project on GitHub?
There are many tutorials on the subject, but they make things too complicated by assuming that contributions must be made.CodeTo a project. So allGitSet up before that.
What if you only need to edit the file, maybe the project README to resolve typing errors?
You don't need to know how to code or how to use Git to do this. However, once you start executing the "pull request", you can do more and collaborate with others on projects! Maybe this will prompt you to contribute code in the future.
I assume you already have one (free)GitHubaccount. If you don’t, go togithub.comAnd get one.
Let me tell you the process.
I went to this pagehttps://web.dev/prefers-color-scheme/I found a possible typo. A point is missing at the end of this line.
I am not a grammatical Nazi, this is just to find an example 😄
I know that the website is hosted on GitHub, and the exact article is hosted here:https://github.com/GoogleChrome/web.dev/tree/master/src/site/content/en/blog/prefers-color-scheme
I open the index.md filehttps://github.com/GoogleChrome/web.dev/blob/master/src/site/content/en/blog/prefers-color-scheme/index.mdDirectly on GitHub and press the pencil icon in the file toolbar. When hovering over it says: "Fork this project and edit the file".
This will display the editor view of the following information:
You are editing a file in a project that does not have write permissions. Committing changes to this file will write it to a new branch in the branch flaviocopes/web.dev, so you can send a pull request.
I can add this point and then explain the changes made in the form at the bottom:
I press the "Suggest file changes" button and a comparison view is displayed.
Here, I can review the changes made to make sure everything is fine, and finally, I can click the "Create pull request" button. Has beenYour forkThe project, which was automatically created by GitHub when you clicked the pencil icon.
At the top of this view, you can see that I am about to submit a PR to PRGoogleChrome/web.dev
Items in my formflaviocopes/web.dev
From my branchpatch-2
give themmaster
Branch.
Pressing the "Create Request Request" button will display another form in which I can write a detailed description of the request.
A pull request can contain many different changes, so in theory, you can edit many files in the same PR, which is why you can add a summary.
The repository has templates for PR texts to help the team manage it. Our PR is very simple, so I deleted the template and only pasted the content from the previous submission message.
Pay attention to the prompt on the right? They told me that the project has a CONTRIBUTING.md file, which explains how to contribute and guidelines. Pretty cool
It seems that we need to sign a CLA (Contributor License Agreement) to complete the PR. In the past, I have signed a Google CLA, so this step is obvious to me, but you may need to resolve this issue. Most projects don't really need it.
I click "Create pull request" and send a PR now!
Now that the project maintainer steps in and accepts it, you just need to wait for an email telling you that it has been merged, or anyone else has any comments.
[...A few hours have passed...]
I received an email and the PR was rejected because the point was actually in the right place! (I do not know).
But anyway, this is one point I want to add: if the PR you accept is not accepted, please don't be angry or frustrated. The maintainers of the project need to spend months or years, and they know better than you what is better for it.
Also, especially for code, the views can be very different, and PRs that you think are great may not be welcome.
It's best to ask before doing a substantive PR to see if this is what the project really needs.
However, this is a topic in itself.
More git tutorials:
- A Git cheat sheet
- Git workflow to manage the work of multiple branches
- The easy way to deal with Git sub-repositories
- Incomplete list of excellent Git tutorials
- Introduction to GitHub Developers
- The complete Git guide
- How to use git bisect to find errors
- How to make the first pull request on GitHub
- How to update Git branch from another branch
- I published the password/API key on GitHub
- Squash Git commit
- How to delete the Git remote