如何参与一个GitHub开源项目
Posted 白乾涛
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何参与一个GitHub开源项目相关的知识,希望对你有一定的参考价值。
A great way to get involved in参与 open source is to contribute to the existing projects you’re using. GitHub is home to more than 5 million open source projects. There are projects for every skill set各个领域 like recipes, HTML/CSS, Ruby, Astrophysics and many more. This guide will cover涵盖 what you might find in a typical project and how to make a great contribution.
Find Projects
We recommend推荐 that you start by finding a project that you’re already (or are interested in) using. Here are a few great places to look:
- GitHub Explore: Popular and trending热门 projects.
- GitHub Stars: Projects starred by other people.
- GitHub Showcases: A way to discover related repositories.相关库
- Designer News: Front-end development and design projects.
A Typical Project
Below are some elements you’re likely to come across遇到 in an open source project on GitHub.
The Community社区
Projects often have a community around them, made up of组成 other users in different (formal or informal) roles:
- Owner is the user or organization that created the project has the project on their account.
- Maintainers维护者 and Collaborators协作者 are the users primarily doing the work on a project and driving the direction驾驶方向. Oftentimes the owner and the maintainer are the same. They have write access权限 to the repository.
- Contributors贡献者 is everyone who has had a pull request merged合并 into a project.
- Community Members are the users who often use and care deeply about the project and are active活跃 in discussions for features and pull requests.
The Docs
The what’s-what of common files in projects.
Readme
Nearly all GitHub projects include a README.md
file. The readme provides a lay of the land for a project with details细节 on how to use, build and sometimes contribute to a project.
Contributing
Projects and project maintainers vary不同, so the best way to contribute will also vary. Keep your eye open for a doc labeled标注 CONTRIBUTING
. Contributing docs detail the specifics about how a project’s maintainer would like to see patches补丁 or features功能 contributed. This can include what tests to write, code syntax语法 style or areas to focus on for patches.
License许可
A LICENSE
file, well, is the license for the project. An open source project’s license informs users what they can and can’t do (e.g., use, modify, redistribute重新发布), and contributors, what they are allowing others to do. There are many ways to license and open source project, you can read more about what each license means at choosealicense.com.
Documentation and Wikis
Many larger projects go beyond不止 a readme to give instructions指导 for how people can use their project. In such cases you’ll often find a link to another file or a folder named ‘docs’ in the repository.
Alternatively另外, the repository may instead代替 use the GitHub wiki to break down documentation.
Contributing to a Project
Now that you’ve found the material资料 for understanding the project, here is how you can take action.
Create an Issue话题
If you find a bug in a project you’re using (and you don’t know how to fix it), have trouble following the documentation or have a question about the project – create an issue! There’s nothing to it很简单 and whatever issue you’re having, you’re likely not the only one, so others will find your issue helpful, too. For more information on how issues work, check out our Issues guide.
Issues Pro Tips专业提示
- Check existing issues for your issue. Duplicating重复 an issue is slower for both parties so search through open and closed issues to see if what you’re running into has been addressed解决 already.
- Be clear about what your problem is: what was the expected outcome, what happened instead? Detail how someone else can recreate the problem.
- Link链接 to demos recreating the problem on things like JSFiddle or CodePen.
- Include system details like what the browser, library or operating system you’re using and its version.
- Paste error output or logs in your issue or in a Gist. If pasting them in the issue, wrap包裹 it in three backticks: ` ``` ` so that it renders呈现 nicely.
Pull Request
If you’re able to patch修复 the bug or add the feature yourself – fantastic太棒了, make a pull request with the code! Be sure you’ve read any documents on contributing, understand the license and have signed a Contributor Licence Agreement (CLA) if required. Once you’ve submitted提交 a pull request the maintainer(s) can compare比较 your branch to the existing one and decide whether or not to incorporate合并 (pull in) your changes.
Pull Request Pro Tips
- Fork the repository and clone it locally. Connect your local to the original原始的 ‘upstream’ repository by adding it as a remote远程. Pull in changes from ‘upstream’ often经常 so that you stay up保持 to date so that when you submit your pull request, merge conflicts合并冲突 will be less likely. See more detailed instructions here.
- Create a branch for your edits.
- Be clear about what problem is occurring出现 and how someone can recreate that problem or why your feature will help. Then be equally同样 as clear about the steps步骤 you took to make your changes.
- It’s best to test. Run your changes against any existing tests if they exist and create new ones when needed. Whether tests exist or not, make sure your changes don’t break破坏 the existing project.
- Include screenshots of the before and after if your changes include differences in html/CSS. Drag and drop拖放 the images into the body of your pull request.
- Contribute in the style of the project to the best of your abilities尽你所能. This may mean using indents缩进, semi colons分号 or comments注释 differently than you would in your own repository, but makes it easier for the maintainer to merge, others to understand and maintain维护 in the future.
Open Pull Requests
Once you’ve opened a pull request, a discussion will start, around your proposed changes. Other contributors and users may chime in参与, but ultimately最终 the decision is made by the maintainer(s). You may be asked to make some changes to your pull request, if so, add more commits to your branch and push them – they’ll automatically go into the existing pull request.
以上是关于如何参与一个GitHub开源项目的主要内容,如果未能解决你的问题,请参考以下文章