Skip to content

Git and GitHub

Git and GitHub

Git is one of the standard version-control systems used by developers to save code and work on code collaboratively as a team. Git is a program run on the command line or Anaconda Prompt. If you use Windows, the gitbash program can be downloaded at Git was created by Linus Torvalds, who also designed the Linux operating system. (now owned by Microsoft) is a website and service used by programmers and open source projects to share code and allow contributors to propose changes to existing code. Both git and are useful for problem solvers working in teams. Before using git and, it is helpful to understand a couple of terms:

  • git - a command line program used to track file changes and collaborate on code with others.
  • repo - short name for "repository". A repo is a directory and its contents.
  • local repo - a directory and its contents on your computer that git knows about.
  • remote repo - a directory and its contents stored in the cloud that git knows about. Useful git commands are summarized below:

  • git clone copy a remote repo from into a local directory

  • git init create a new local repo in the current folder

  • git remote add origin link a local repo to a remote repo on

  • git add . add all files and changes to the local repo

  • git commit -m "commit message" commit the changes in the local repo with the message "commit message"

  • git push origin master push local changes up to the remote repo

  • git pull origin master pull down the version in the remote repo into the local repo

Cloning a repo

One common operation to complete with git is to clone a repo from and save it locally. This means you copy all the files stored in the remote repo on onto your local computer. Cloning a repo from is accomplished with:

$ git clone

This command copies the repo named repo from the user named user to a local computer. To clone the repo for MicroPython, use:

$ git clone

Creating and synching a remote repo on with a local repo

Another common task to complete with git is to synch a remote repo on with a local repo on your local computer. This is useful when you want to keep the files in a particular project synched across multiple computers. Synched remote and local repos are also useful for a group of problem solvers working on the same project. Each team member has access to the same remote repo on and each team member has the same local repo on their computer.

Create a remote repo on

First, go to and create a new account. Log in and create a new repo. It is a good idea to include a license and a .gitignore file. For a Python project, the .gitignore file for Python is a good start. Two common licenses for open source projects (projects you are willing to share with others) are the GNU General Public License v3.0 and the MIT License.

Second, create a local directory and cd into it. Initialize a git repo locally in that directory. Then synch the local folder with the remote repo on

$ mkdir newproject
$ cd newproject
$ git init
$ git remote add origin
$ git pull origin master

Add, commit and push changes up to

Third, work on the project locally. For example, you could edit one of the files in the directory newproject or create a new file in the directory newproject.

Finally, save your work and commit the changes you made with git. Push those changes up to the remote repo on

$ git add .
$ git commit -m "commit message"
$ git push origin master

Pull the most recent version from before each work session

If using git and, remember to pull the most recent version of the repo down from before you make any changes locally. If changes are made locally before the version of the repo on is synched, the local repo and remote repo will be out of synch.

$ git pull origin master

After local changes are made, save the changes and push to

$ git add .
$ git commit -m "commit message"
$ git push orign master