want to work on a new feature, please create a [change request].
Keep in mind the guidance given and let people advise you. It might be that
there are easier solutions to the problem you perceive and want to address.
It might be that what you want to achieve can already be done by
configuration or [customization].
[bug report]: reporting-a-bug.md
[documentation issue]: reporting-a-docs-issue.md
[change request]: requesting-a-change.md
[customization]: ../customization.md
## Learning about pull requests
Pull requests are a concept layered on top of Git by services that provide Git
hosting. Before you consider making a pull request, you should familiarize
yourself with the documentation on GitHub, the service we are using. The
following articles are of particular importance:
1. [Forking a repository]
2. [Creating a pull request from a fork]
3. [Creating a pull request]
Note that they provide tailored documentation for different operating systems
and different ways of interacting with GitHub. We do our best in the
documentation here to describe the process as it applies to Material for MkDocs
but cannot cover all possible combinations of tools and ways of doing things.
It is also important that you understand the concept of a pull-request in
general before continuing.
[Forking a repository]: https://docs.github.com/en/get-started/quickstart/fork-a-repo
[Creating a pull request from a fork]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork
[Creating a pull request]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
## Pull request process
In the following, we describe the general process for making pull requests. The
aim here is to provide the 30k ft overview before describing details later on.
### Preparing changes and draft PR
The diagram below describes what typically happens to repositories in the
process or preparing a pull request. We will be discussing the review-revise
process below. It is important that you understand the overall process first
before you worry about specific commands. This is why we cover this first before
providing instructions below.
``` mermaid
sequenceDiagram
autonumber
participant mkdocs-material
participant PR
participant fork
participant local
mkdocs-material ->> fork: fork on GitHub
fork ->> local: clone to local
local ->> local: branch
loop prepare
loop push
loop edit
local ->> local: commit
end
local ->> fork: push
end
mkdocs-material ->> fork: merge in any changes
fork ->>+ PR: create draft PR
PR ->> PR: review your changes
end
```
1. The first step is that you create a fork of the Material for MkDocs
repository, either [mkdocs-material] or [mkdocs-material-insiders]
(only accessible to sponsors). This provides you with a repository that you
can push changes to. Note that it is not possible to have more than one fork
of a given repository at any point in time. So, the fork you create will be
*the* fork you have.
2. Once it is made, clone it to your local machine so you can start working on
your changes.
3. All contributions should be made through a 'topic branch' with a name that
describes the work being done. This allows you to have more than one piece
of work in progress and, if you are working with the public version, also
shows others clearly that the code contained is work in progress. The topic
branch will be relatively short-lived and will disappear at the end, when
your changes have been incorporated into the codebase.
Initially, create the pull request **as a draft**. You do this [through the
various interfaces that GitHub provides]. Which one you use is entirely up to
you. We do not provide specific instructions for using the interfaces as GitHub
provide all the information that should be necessary.
[through the various interfaces that GitHub provides]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
### Commits, messages, mistakes and 'squash'
### Deleting branches
Once the pull request has been merged into the master branch of the Material
for MkDocs repository, you should remove the branch both from the fork on
GitHub and from the local clone on your computer. This avoids possible
confusion about the state of development.
First, switch back to the `master` branch with `git switch master` and then
delete the branch used for the PR using `git branch -d <name>`.
### Subsequent Pull Requests
It is important that subsequent pull requests are started from an up-to-date
history of the `master` branch. One way to achieve this is to delete the fork
and start with an entirely new one next time round.
If you contribute to Material for MkDocs more often or just happen to be
doing two or more pull requests in succession, you can also just make sure
to sync your fork (using the GitHub UI) and pull from it into your local
repository. So, just delete the topic branch you created (both locally and in
your fork) and pull from the main repository's `master` branch into your
`master` branch before starting work on a new pull request.
## Dos and Don'ts
1.**Don't** just create a pull request with changes that are not explained.
2.**Do** discuss what you intend to do with people in the discussions so that the
rational for any changes is clear before you write or modify code.
3.**Do** link to the discussion or any issues to provide the context for a pull
request.
4.**Do** ask questions if you are uncertain about anything.
5.**Do** ask yourself if what you are doing benefits the wider community and
makes Material for MkDocs a better product.
6.**Do** ask yourself if the cost of making the changes stands in a good
relation to the benefits they will bring. Some otherwise sensible changes can
add complexity for comparatively little gain, might break existing behaviour
or might be brittle when other changes need to be made.
7.**Do** merge in concurrent changes frequently to minimize the chance of
conflicting changes that may be difficult to resolve.