Text of numpy.org › doc › 1.16 › dev › gitwash › development_workflow.html as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Development workflow — NumPy v1.16 Manual

Scipy.org Docs NumPy v1.16 Manual Contributing to NumPy Working with NumPy source code index next previous Development workflow ¶ You already have your own forked copy of the NumPy repository, by following Making your own copy (fork) of NumPy , Set up your fork , you have configured git by following Git configuration , and have linked the upstream repository as explained in Linking your repository to the upstream repo .

What is described below is a recommended workflow with Git. Basic workflow ¶ In short: Start a new feature branch for each set of edits that you do. See below . Hack away! See below When finished: Contributors : push your feature branch to your own Github repo, and create a pull request . Core developers If you want to push changes without further review, see the notes below . This way of working helps to keep work well organized and the history as clear as possible.

See also There are many online tutorials to help you learn git . For discussions of specific git workflows, see these discussions on linux git workflow , and ipython git workflow . Making a new feature branch ¶ First, fetch new commits from the upstream repository: git fetch upstream Then, create a new branch based on the master branch of the upstream repository: git checkout - b my - new - feature upstream / master The editing workflow ¶ Overview ¶ # hack hack git status # Optional git diff # Optional git add modified_file git commit # push the branch to your own Github repo git push origin my - new - feature In more detail ¶ Make some changes.

When you feel that you’ve made a complete, working set of related changes, move on to the next steps. Optional: Check which files have changed with git status (see git status ). You’ll see a listing like this one: # On branch my-new-feature # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: README # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # INSTALL no changes added to commit ( use "git add" and / or "git commit -a" ) Optional: Compare the changes with the previous version using with git diff ( git diff ).

This brings up a simple text browser interface that highlights the difference between your files and the previous version. Add any relevant modified or new files using git add modified_file (see git add ). This puts the files into a staging area, which is a queue of files that will be added to your next commit. Only add files that have related, complete changes. Leave files with unfinished changes for later commits. To commit the staged files into the local copy of your repo, do git commit .

At this point, a text editor will open up to allow you to write a commit message. Read the commit message section to be sure that you are writing a properly formatted and sufficiently detailed commit message. After saving your message and closing the editor, your commit will be saved. For trivial commits, a short commit message can be passed in through the command line using the -m flag. For example, git commit -am "ENH: Some message" .

In some cases, you will see this form of the commit command: git commit -a . The extra -a flag automatically commits all modified files and removes all deleted files. This can save you some typing of numerous git add commands; however, it can add unwanted changes to a commit if you’re not careful. For more information, see why the -a flag? - and the helpful use-case description in the tangled working copy problem . Push the changes to your forked repo on github : git push origin my - new - feature For more information, see git push .

Note Assuming you have followed the instructions in these pages, git will create a default link to your github repo called origin . In git >= 1.7 you can ensure that the link to origin is permanently set by using the --set-upstream option: git push -- set - upstream origin my - new - feature From now on git will know that my-new-feature is related to the my-new-feature branch in your own github repo. Subsequent push calls are then simplified to the following: git push You have to use --set-upstream for each new branch that you create.

It may be the case that while you were working on your edits, new commits have been added to upstream that affect your work. In this case, follow the Rebasing on master section of this document to apply those changes to your branch. Writing the commit message ¶ Commit messages should be clear and follow a few basic rules. Example: ENH : add functionality X to numpy .< submodule >. The first line of the commit message starts with a capitalized acronym ( options listed below ) indicating what type of commit this is .

Then a blank line , then more text if needed . Lines shouldn 't be longer than 72 characters . If the commit is related to a ticket , indicate that with "See #3456" , "See ticket 3456" , "Closes #3456" or similar . Describing the motivation for a change, the nature of a bug for bug fixes or some details on what an enhancement does are also good to include in a commit message. Messages should be understandable without looking at the code changes.

A commit message like MAINT: fixed another one is an example of what not to do; the reader has to go look for context elsewhere. Standard acronyms to start the commit message with are: API : an ( incompatible ) API change BENCH : changes to the benchmark suite BLD : change related to building numpy BUG : bug fix DEP : deprecate something , or remove a deprecated object DEV : development tool or utility DOC : documentation ENH : enhancement MAINT : maintenance commit ( refactoring , typos , etc . ) REV : revert an earlier commit STY : style fix ( whitespace , PEP8 ) TST : addition or modification of tests REL : related to releasing numpy Asking for your changes to be merged with the main repo ¶ When you feel your work is finished, you can create a pull request (PR).

Github has a nice help page that outlines the process for filing pull requests . If your changes involve modifications to the API or addition/modification of a function, you should initiate a code review. This involves sending an email to the NumPy mailing list with a link to your PR along with a description of and a motivation for your changes. Rebasing on master ¶ This updates your feature branch with changes from the upstream NumPy github repo.

If you do not absolutely need to do this, try to avoid doing it, except perhaps when you are finished. The first step will be to update the remote repository with new commits from upstream: git fetch upstream Next, you need to update the feature branch: # go to the feature branch git checkout my - new - feature # make a backup in case you mess up git branch tmp my - new - feature # rebase on upstream master branch git rebase upstream / master If you have made changes to files that have changed also upstream, this may generate merge conflicts that you need to resolve.

See below for help in this case. Finally, remove the backup branch upon a successful rebase: git branch - D tmp Note Rebasing on master is preferred over merging upstream back to your branch. Using git merge and git pull is discouraged when working on feature branches. Recovering from mess-ups ¶ Sometimes, you mess up merges or rebases. Luckily, in Git it is relatively straightforward to recover from such mistakes. If you mess up during a rebase: git rebase -- abort If you notice you messed up after the rebase: # reset branch back to the saved point git reset -- hard tmp If you forgot to make a backup branch: # look at the reflog of the branch git reflog show my - feature - branch 8630830 my - feature - branch @ { 0 }: commit : BUG : io : close file handles immediately 278 dd2a my - feature - branch @ { 1 }: rebase finished : refs / heads / my - feature - branch onto 11 ee694744f2552d 26 aa21a my - feature - branch @ { 2 }: commit : BUG : lib :

The rest of this page is on the live site.