1(ch_contributing)= 2 3# Contributing to PETSc 4 5As you gain experience in building, using, and debugging with PETSc, you 6will be able to contribute! 7 8Before contributing code to PETSc, please read {any}`style`. You may also 9be interested to read about {any}`design`. 10 11PETSc uses [Git](https://git-scm.com/), [GitLab](https://gitlab.com/petsc/petsc), 12and its testing system, for its source code management. 13All new code in PETSc is accepted via merge requests (MRs). 14 15By submitting code, the contributor gives irretrievable consent to the 16redistribution and/or modification of the contributed source code as 17described in the [PETSc open-source license](https://gitlab.com/petsc/petsc/-/blob/main/CONTRIBUTING). 18 19## How-Tos 20 21Some of the source code is documented to provide direct examples/templates for common 22contributions, adding new implementations for solver components: 23 24- [Add a new PC type](https://gitlab.com/petsc/petsc/-/blob/main/src/ksp/pc/impls/jacobi/jacobi.c) 25- [Add a new KSP type](https://gitlab.com/petsc/petsc/-/blob/main/src/ksp/ksp/impls/cg/cg.c.html) 26- [Add a new subclass of a matrix type (implementation inheritance)](https://gitlab.com/petsc/petsc/-/blob/main/src/mat/impls/aij/seq/superlu/superlu.c.html) 27 28(sec_git)= 29 30(sec_setup_git)= 31 32## Setting up Git 33 34We provide some information on common operations here; for more details, see `git help`, `man git`, or [the Git book](https://git-scm.com/book/en/). 35 36- [Install Git](https://git-scm.com/downloads) if it is not already installed on your machine, then see below to obtain PETSc. 37- [Set up your Git environment](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) to establish your identity. 38- To stay oriented when working with branches, we encourage configuring 39 [git-prompt](https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh). 40- To get tab-completion for Git commands, one can download and then source 41 [git-completion.bash](https://raw.github.com/git/git/master/contrib/completion/git-completion.bash). 42 43## Obtaining the development version of PETSc 44 45- If you have write access to the PETSc [GitLab repository](https://gitlab.com/petsc/petsc), use `git clone git@gitlab.com/petsc/petsc` 46 (or use a clone you already have). 47 48- Otherwise, [Create a fork](https://gitlab.com/petsc/petsc/-/forks/new) (your own copy of the PETSc repository). 49 50 - You will be asked to "Select a namespace to fork the project"; click the green "Select" button. 51 52 - If you already have a clone on your machine of the PETSc repository you would like to reuse 53 54 ```console 55 $ git remote set-url origin git@gitlab.com:YOURGITLABUSERNAME/petsc.git 56 ``` 57 58 - otherwise 59 60 ```console 61 $ git clone git@gitlab.com:YOURGITLABUSERNAME/petsc.git 62 ``` 63 64PETSc can now be configured as specified on the 65[Installation page](https://petsc.org/release/install/) 66 67To update your copy of PETSc 68 69```console 70$ git pull 71``` 72 73Once updated, you will usually want to rebuild it completely 74 75```console 76$ make reconfigure all 77``` 78 79This is equivalent to 80 81```console 82$ $PETSC_DIR/$PETSC_ARCH/lib/petsc/conf/reconfigure-$PETSC_ARCH.py && make all 83``` 84 85```{toctree} 86:maxdepth: 1 87 88developingmr 89submittingmr 90pipelines 91``` 92