Setting up git for NumPy development#

To contribute code or documentation, you first need

  1. git installed on your machine

  2. a GitHub account

  3. a fork of NumPy

Install git#

You may already have git; check by typing git --version. If it’s installed you’ll see some variation of git version 2.11.0. If instead you see command is not recognized, command not found, etc., install git.

Then set your name and email:

git config --global
git config --global "Your Name"

Create a GitHub account#

If you don’t have a GitHub account, visit to create one.

Create a NumPy fork#

Forking has two steps – visit GitHub to create a fork repo in your account, then make a copy of it on your own machine.

Create the fork repo#

  1. Log into your GitHub account.

  2. Go to the NumPy GitHub home.

  3. At the upper right of the page, click Fork:


    You’ll see


    and then you’ll be taken to the home page of your forked copy:


Make the local copy#

  1. In the directory where you want the copy created, run

    git clone

    You’ll see something like:

    $ git clone
    Cloning into 'numpy'...
    remote: Enumerating objects: 12, done.
    remote: Counting objects: 100% (12/12), done.
    remote: Compressing objects: 100% (12/12), done.
    remote: Total 175837 (delta 0), reused 0 (delta 0), pack-reused 175825
    Receiving objects: 100% (175837/175837), 78.16 MiB | 9.87 MiB/s, done.
    Resolving deltas: 100% (139317/139317), done.

    A directory numpy is created on your machine. (If you already have a numpy directory, GitHub will choose a different name like numpy-1.)

    $ ls -l
    total 0
    drwxrwxrwx 1 bjn bjn 4096 Jun 20 07:20 numpy
  1. Give the name upstream to the main NumPy repo:

    cd numpy
    git remote add upstream
  2. Set up your repository so git pull pulls from upstream by default:

    git config branch.main.remote upstream
    git config branch.main.merge refs/heads/main
  3. Initialize the required git submodules:

    git submodule update --init
  4. Pull from upstream to get latest tag information:

    git pull

Look it over#

  1. The branches shown by git branch -a will include

    • the main branch you just cloned on your own machine

    • the main branch from your fork on GitHub, which git named origin by default

    • the main branch on the main NumPy repo, which you named upstream.


    If upstream isn’t there, it will be added after you access the NumPy repo with a command like git fetch or git pull.

  2. The repos shown by git remote -v show will include your fork on GitHub and the main repo:

    upstream (fetch)
    upstream (push)
    origin (fetch)
    origin (push)
  3. git config --list will include Name

Optional: set up SSH keys to avoid passwords#

Cloning your NumPy fork repo required no password, because it read the remote repo without changing it. Later, though, submitting your pull requests will write to it, and GitHub will ask for your username and password – even though it’s your own repo. You can eliminate this authentication without compromising security by setting up SSH keys .

If you set up the keys before cloning, the instructions above change slightly. Instead of

git clone


git clone

and instead of showing an https URL, git remote -v will show

origin (fetch)
origin (push)

If you have cloned already and want to start using SSH, see Switching remote URLs from HTTPS to SSH .