Creating a patch for PETSc using git
Clone the Repository
If you haven't already, the first step is to obtain a recent copy of the PETSc repository:
$> git clone https://bitbucket.org/petsc/petsc.git $> cd petsc/
This creates a new folder 'petsc' containing the development repository and changes right into it.
If all the changes you applied to the PETSc code should enter the patch, proceed to the next section.
Otherwise, if you have already cloned the repository at some earlier stage and played around with it, but you don't want to keep any of your changes to files, reset the current work tree using
$:petsc> git checkout -f
To selectively bring files back to their original state, first run
$:petsc> git status
to get a list of modified files. For each file
f to be reverted, issue
$:petsc> git checkout path/to/f
Branch From Master
Create a new branch with a name of your choice (avoid spaces), e.g.
$:petsc> git checkout -b my-feature-name master
Note that creating a branch is a natural work flow with git. Any bad experiences you had with older version control systems do not apply here.
Apply your Changes
If you haven't already, apply all the changes to the sources which should go into the patch. Please try to make a patch self-contained, dealing with only one aspect or module at a time (for example: Fixes to documentation).
Commit your Changes
Once you completed updating the source tree, let's first check a summary of changed files:
$:petsc> git status
If all the files shown as 'modified' should indeed be patched, commit you work using
$:petsc> git commit -a
Write a descriptive commit message. You can also incrementally select specific files to include in the commit using:
$:petsc> git add path/to/file1 path/to/file2
and commit them using
$:petsc> git commit
A GUI Client, including the built-in
git gui, can be helpful for committing.
Create a patch series
You can commit multiple times to the same branch before creating a patch. Once your changes are completed, create a patch series since
$:petsc> git format-patch master
This will create one patch file per commit in your branch
my-feature-name, numbered sequentially like
Send it over
Please send the newly created patch file(s) to email@example.com with an explanation of what they are for.