Skip to content

Using Git And GitHub

Jukka Lehtosalo edited this page Mar 30, 2016 · 4 revisions

Simple workflow

If you are just starting mypy development or contribute only occasionally, or if the second workflow below feels too complicated, you can follow this simple workflow:

  1. Set up Git on your computer instruction
  2. Create a GitHub account, if you don't have one.
  3. Navigate to https://www.github.com/python/mypy and "fork" the repository. This gives you a clone of the repo hosted at GitHub under your GitHub account.
  4. Clone a local copy of your own fork of the repository. This creates a directory mypy under the current working directory. For example:
$ git clone https://github.com/<your-account>/mypy.git
  1. Do any commits in the local clone of the repo (any git tutorial explains this).
  2. Push changes to the clone of the repo hosted under your GitHub account:
$ git push
  1. Create an issue for your commit (if it doesn't exist yet).
  2. Post the URL of your hosted git repo clone as a comment related to the issue.
  • Mentioning the commit ids (use git log or the GitHub repo browser to browse them) may help locate your changes.
  • Even better, perform all your commits in a branch, and mention the URL of the branch. No commit ids needed. See the git resources below for the details.
  1. The mypy developers will review and merge your changes to the main repo if your pull request looks good. This often takes several days or even longer during vacations, etc.

Using GitHub pull requests

Here is a suggested git workflow for contributing code changes:

  1. Set up Git on your computer (https://help.github.com/articles/set-up-git).
  2. Create a GitHub account (unless you already have one).
  3. Navigate to https://www.github.com/python/mypy and "fork" the repository. This gives you a clone of the repo hosted at GitHub under your GitHub account.
  4. Clone a local copy of your own fork of the repository. This creates a directory {{{mypy}}} under the current working directory. For example:
$ git clone https://github.com/<your-account>/mypy.git
  1. Change the directory to the original cloned repo (mypy):
$ cd mypy
  • Create a new branch in the local mypy repo for your changes (replace with a descriptive but short name):

$ git checkout -b

 * Now commit some changes to your local copy of the repository.
 * Test your changes a bit and fix any bugs you find.
 * Push the changes to the repo hosted under your GitHub account:

$ git push -u origin

 * Send a pull request according to these instructions:
   https://help.github.com/articles/creating-a-pull-request
 * Now the mypy developers will review and merge your changes. This may take a few days (or more), depending on how busy the developers are.
 * You probably want to check out the master branch again before continuing from step 5 for another contribution:

$ git checkout master


## More information

The above description did not mention some important things such as how to fetch and merge changes from the main mypy repo. Read this for more information:

 * https://help.github.com/articles/fork-a-repo

Git tutorials for svn users:

 * https://git.wiki.kernel.org/index.php/GitSvnCrashCourse

General git information:

  * [Pro Git (online book)](http://git-scm.com/book)
  * [Introduction to git at GitHub](http://learn.github.com/p/intro.html)

More about branching in git (it's not like in Subversion):

  * http://learn.github.com/p/branching.html
  * http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

Using hg to access git repositories (not verified; please edit this and add a comment if you try this):

 * http://hg-git.github.com/ 
 * http://mercurial.selenic.com/wiki/HgGit