Master GitHub Contributions: Fork, Clone, Commit, and Pull Request Step‑by‑Step
This guide walks through the complete workflow for contributing code to a GitHub project, covering forking, cloning, creating a development branch, committing changes, pushing them, opening a pull request, and synchronising a fork with upstream updates.
GitHub hosts countless open‑source projects, and developers can contribute code to them. This guide demonstrates the full contribution workflow using a sample repository githubTest owned by user Alvin.
1. Fork the repository
Harry clicks the “Fork” button on the project page, creating a personal copy of githubTest under his own GitHub account, including all files, history, and issues.
2. Clone to local machine
After forking, Harry clones the repository to his computer with git clone https://github.com/yychuyu/githubTest. The URL is shown in the article.
3. Create a development branch, edit, and commit
Harry creates a dev branch, makes his changes, and commits them locally. He avoids committing directly to master and later merges dev back into master.
4. Push changes to the fork
Using git push, Harry uploads the new commits to his fork on GitHub, where they appear in the repository’s commit history.
5. Open a pull request
Harry clicks “New pull request” on GitHub, reviews the diff, optionally adds a description, and creates the pull request. If GitHub reports “Able to merge”, the request can be merged by the original author.
Synchronising the fork after upstream changes
If Alvin updates the original repository, Harry must fetch, merge, and push the changes to keep his fork up‑to‑date.
1. Fetch
git fetch [email protected]:yychuyu/githubTest.git master:latestThis copies the upstream master branch into a local latest branch.
2. Merge
Harry checks out his master branch and merges latest into it.
3. Push
Finally, he pushes the updated master back to his fork.
Following these steps, Harry successfully contributes to the githubTest project and can continue making further contributions.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
