Git (and Python) workflow when contributing to the official KiCad libraries

This description of the Git (and Python) workflow when contributing to the official KiCad libraries is intended as a simple walk-through how-to for users new to KiCad and Git but who have enough know-how to open a terminal and use the command line.

Contributing to KiCad
Instead of effort being wasted by any number of different designers recreating their own versions of symbols, footprints or 3d models of unknown quality, by contributing to the official libraries, the combined effort will help these to grow benefiting all KiCad users.

The KLC
The KiCad Library Convention (KLC) is a set of requirements for contributing to the official KiCad libraries.

The things that are really important still need to be hand checked. This is the main work that library maintainers do. For example the pin numbers, names and types still needs to be compared to the datasheet, for footprints a dimension check is also required.

KiCad utilities
Before making a pull request use the KiCad utilities (Python scripts) to check whether the parts you are considering submitting are KLC compliant. They mainly check stuff that is only important for having a consistent library.

Travis CI
On GitHub Travis CI checks KLC compliance of footprint files and symbol libraries.

Usage
See the README.md file. Run these in a terminal window using Python

Use pcb/check_kicad_mod.py to check KLC compliance of footprint files.

Use schlib/checklib.py to check KLC compliance of schematic symbol libraries.

GitHub
GitHub simply hosts a Git server and provides a nice web interface. The official KiCad libraries are hosted on GitHub.

One time SSH key setup

 * If you don't have one already, create a GitHub account.
 * On Windows install Git for Windows
 * Generate a new SSH key and add it to the ssh-agent.
 * Add the SSH key to your GitHub account.

Create a fork (e.g. footprints)
At https://github.com/KiCad/kicad-footprints click Fork at the top right, to fork your own copy of KiCad/kicad-footprints to your GitHub account.

Note that https://github.com/KiCad/kicad-footprints is referred to as "upstream" and your fork https://github.com/YOUR-USERNAME/kicad-footprints as "origin".

Git Bash
To go to your home directory, enter with no other text To list the files and folders in your current directory, enter To go into one of your listed directories, enter To go up one directory, enter

Git
Git is an open source distributed version control system (VCS) and is available for multiple OS. It is available for free.

The command line is the only place you can run all Git commands, most of the GUIs implement only a partial subset of Git functionality for simplicity. If you know how to run the command-line version, you can probably also figure out how to run the GUI version, while the opposite is not necessarily true.

Initial setup
The first thing to do is to set your user name and email address, every Git commit will use this information. Use the git config command with the --global option this only needs to be done once:

To setup the user name To setup the user email address

To check the user name To check the user email address

Usage (e.g. for footprints)
For help on common Git commands, enter:

For the manual page on a particular command, (e.g. add) enter:

To have the files in your fork on your computer, create a clone of your fork locally on your computer with:

The commands below are done in the folder of your working copy of the fork (# marks a comment).

To update:

Add the official KiCad repo as another remote. This takes care of keeping all branches up-to-date between your downstream repository or fork ("origin") and the KiCad repo ("upstream"). This only needs to be done once:

Make a separate pull request (PR) for each separate library, (e.g. Button_Switch_THT.pretty vs. Potentiometer_THT.pretty). To do this you need to have one branch per contribution:

Make your changes then:

Go to https://github.com/YOUR-USERNAME/kicad-footprints and click the "Compare & pull request" button to do the PR. Complete the form and click "Create pull request".

If you then are requested to do some changes you would need to checkout the correct branch and then do your changes:

Do your changes:

To keep your fork current with the upstream repository:

KiCad

 * Contributing to the KiCad libraries
 * KiCad EDA, GitHub repositories
 * KiCad/kicad-library-utils
 * KiCad Library Convention
 * Library management in KiCad version 5, KiCad.info Forums

Tutorials

 * Tutorial: How to make a symbol by Rene Poschl, KiCad.info Forums
 * Tutorial: How to make a footprint (From scratch)? by Rene Poschl, KiCad.info Forums

Python

 * Python, downloads

Git

 * Git

Tutorials

 * gittutorial, a tutorial introduction to Git
 * Getting Git Right, Atlassian.com

Github

 * GitHub Glossary

Tutorials

 * GitHub Guides
 * Introduction to Git with Scott Chacon of GitHub, a good explanation what Git is and how the basics work