GitHub Workflow
This document introduces the GitHub workflow of the DragonOS community. It includes suggestions to help you keep your local environment in sync with the upstream community repository, as well as some Git commit conventions.
This document uses the main DragonOS repository as an example. The same workflow applies to the other repositories of the community.
1. Create a fork on GitHub
- Open https://github.com/DragonOS-Community/DragonOS
- Click the
Forkbutton in the upper right corner to create a fork under your own account.
2. Clone the main repository to your computer
Clone the main repository to your computer (note: not the forked repository under your account).
git clone https://github.com/DragonOS-Community/DragonOS
# Or: git clone git@github.com:DragonOS-Community/DragonOS
cd DragonOSNext, add your fork as a remote. Suppose your name is zhangsan, then run:
Remember to replace the URL with the URL of the repository under your account.
git remote add zhangsan https://github.com/zhangsan/DragonOS
# Or: git remote add zhangsan git@github.com:zhangsan/DragonOS
# Never push to the remote master branch
git remote set-url --push origin no_push
# Confirm that your remotes are set up correctly
git remote -v3. Create a working branch
Remember: never commit on your local master branch. Keep the master branch identical to the master branch of the community repository.
Before you start developing, create a new branch. Each pull request should use a new, clean branch.
First, switch to your local master branch (or main branch) and synchronize it with the remote.
git fetch origin
git checkout masterCreate your working branch:
git checkout -b patch-my-featureNote that the branch name should briefly explain what this pull request does.
Now you can start developing!
4. Keep your branch in sync with the latest remote code
During development, you need to periodically merge code from the community's main repository into your local working branch. If you do not synchronize with the main repository for a long time, many conflicts will arise, and it may even become difficult to get your changes merged into the main repository.
Before running the following commands, switch to your development branch, then run:
git fetch origin
git rebase origin/masterPlease note: do not use git pull to merge code from the main repository into your development branch. Be sure to use the commands above, because git pull creates merge commits, which clutter the commit history and make the commit history of your pull request hard to understand.
5. Commit your changes
Generally, you can simply commit directly.
git commitYou may want to commit your changes frequently so that you can roll back easily.
6. Push to GitHub
When your pull request is ready for review, push your working branch to your repository on GitHub.
Taking the remote zhangsan above as an example, the command is:
git push zhangsan patch-my-feature7. Disable GitHub's email privacy setting
Since you need to collaborate with others, GitHub's built-in email privacy feature may cause problems. Please disable it before submitting a pull request, otherwise your pull request will not pass review.
- Open the GitHub website and sign in to your account.
- Open the Email settings page.
- Under "Primary email address", find "Keep my email addresses private" and uncheck it.
8. Create a new pull request
- Open your forked repository on GitHub:
https://github.com/<username>/DragonOS - Click the
Compare & Pull Requestbutton in the upper right corner, then select the branchpatch-my-feature, with the target set to themasterbranch (ormainbranch) of the community's main repository. - For further requirements on pull requests, see the Pull Request Guide.