To avoid potentially having to download and build many derivations, you can base on a specific [Git commit](https://www.git-scm.com/docs/gitglossary#def_commit) instead:
- The commit of the latest `nixpkgs-unstable` channel, available [here](https://channels.nixos.org/nixpkgs-unstable/git-revision).
- The commit of a local Nixpkgs downloaded using [nix-channel](https://nixos.org/manual/nix/stable/command-ref/nix-channel), available using `nix-instantiate --eval --expr '(import <nixpkgs/lib>).trivial.revisionWithDefault null'`
- If you're using NixOS, the commit of your NixOS installation, available with `nixos-version --revision`.
You can use this commit instead of `upstream/master` in the above command:
```bash
# Here, b9c03fbb is an example commit from nixpkgs-unstable
git switch --create update-hello b9c03fbb
```
3. Make your changes in the local Nixpkgs repository and:
- Adhere to both the [general code conventions][code-conventions], and the relevant [specific code conventions][overview].
- Test the changes.
- If necessary, document the changes.
See the [overview section][overview] for more specific information.
4. Commit your changes using `git commit`.
Make sure to adhere to the [commit conventions](#commit-conventions).
Repeat the steps 3-4 as many times as necessary.
Advance to the next step once all the commits make sense together.
You can view your commits with `git log`.
5. Push your commits to your fork of Nixpkgs:
```
git push --set-upstream origin HEAD
```
The above command will output a link to directly do the next step:
```
remote: Create a pull request for 'update-hello' on GitHub by visiting:
remote: https://github.com/myUser/nixpkgs/pull/new/update-hello
```
6. [Create 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#creating-the-pull-request) from the new branch in your Nixpkgs fork to the upstream Nixpkgs repository.
Use the branch from step 1 as the PR's base branch.
Go through the [pull request template][pr-template].
7. Respond to review comments and potentially to CI failures and merge conflicts by updating the PR.
Always keep it in a mergeable state.
The non-technical side of this process is covered in [I opened a PR, how do I get it merged?](#i-opened-a-pr-how-do-i-get-it-merged).
The [ofborg](https://github.com/NixOS/ofborg) CI system will perform checks to ensure code quality.
You can see the results at the bottom of the PR.
See [the ofborg Readme](https://github.com/NixOS/ofborg#readme) for more details.
- To add new commits, repeat steps 3-4 and push the result:
```
git push
```
- To change existing commits, [rewrite the Git history](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History).
Useful Git commands for this are `git commit --patch --amend` and `git rebase --interactive`.
With a rewritten history you need to force-push the commits:
```
git push --force-with-lease
```
- If there are merge conflicts, you will have to [rebase the branch](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) onto the current **base branch**.
Sometimes this can be done [on GitHub directly](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/keeping-your-pull-request-in-sync-with-the-base-branch#updating-your-pull-request-branch).
To rebase locally:
```
git fetch upstream
git rebase upstream/master
git push --force-with-lease
```
Use the base branch from step 1 instead of `upstream/master`.
- If you need to change the base branch, [rebase][rebase].
8. If your PR is merged and [acceptable for releases][release-acceptable], you may [backport][pr-backport] it.
### Pull request template
[pr-template]: #pull-request-template