Skip to content

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 ​

  1. Open https://github.com/DragonOS-Community/DragonOS
  2. Click the Fork button 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).

shell
git clone https://github.com/DragonOS-Community/DragonOS
# Or: git clone git@github.com:DragonOS-Community/DragonOS

cd DragonOS

Next, 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.

shell
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 -v

3. 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.

shell
git fetch origin
git checkout master

Create your working branch:

shell
git checkout -b patch-my-feature

Note 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:

shell
git fetch origin
git rebase origin/master

Please 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.

shell
git commit

You 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:

shell
git push zhangsan patch-my-feature

7. 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.

  1. Open the GitHub website and sign in to your account.
  2. Open the Email settings page.
  3. Under "Primary email address", find "Keep my email addresses private" and uncheck it.

8. Create a new pull request ​

  1. Open your forked repository on GitHub: https://github.com/<username>/DragonOS
  2. Click the Compare & Pull Request button in the upper right corner, then select the branch patch-my-feature, with the target set to the master branch (or main branch) of the community's main repository.
  3. For further requirements on pull requests, see the Pull Request Guide.