How to turn your project to a Git repo and share it

Objectives

  • Turn our own coding project (small or large, finished or unfinished) into a Git repository.

  • Be able to share a repository on the web to have a backup or so that others can reuse and collaborate or even just find it.

Instructor note

  • 10 min introduction and setup

  • 25 min exercise

  • 15 min discussion

Exercise

Illustration of how we turn a project into a Git repository and share it

From a bunch of files to a local repository which we then share on GitHub.

Exercise: Turn your project to a Git repo and share it (25 min)

  1. Create a new directory called myproject with one or few files in it. This represents our own project. It is not yet a Git repository. You can try that with your own project or use a simple placeholder example.

  2. Turn this new directory into a Git repository.

  3. Share this repository on GitHub (or GitLab, since it really works the same).

We offer three different paths of how to do this exercise.

  • Via GitHub web interface: easy and can be a good starting point if you are completely new to Git.

  • VS Code is quite easy, since VS Code can offer to create the GitHub repositories for you.

  • Command line: you need to create the repository on GitHub and link it yourself.

Create an repository on GitHub

First log into GitHub, then follow the screenshots and descriptions below.

Screenshot on GitHub before a new repository form is opened

Click on the “plus” symbol on top right, then on “New repository”.

Then:

Screenshot on GitHub just before a new repository is created

Choose a repository name, add a short description, and in this case make sure to check “Add a README file”. Finally “Create repository”.

Upload your files

Now that the repository is created, you can upload your files:

Screenshot on GitHub just before uploading files

Click on the “+” symbol and then on “Upload files”.

Remote repositories

In this exercise we have pushed our local repository to a remote repository. You can learn how to work with remote repositories in detail in the collaborative distributed version control lesson.

To store your Git data on another server, you use remotes. A remote is a repository on its own, with its own branches. We can push changes to the remote and pull from the remote.

You might use remotes to:

  • Back up your own work or make your work findable.

  • To collaborate with other people.

There are services that can be a remote:

  • If you have a server you can SSH to, you can use that as a remote.

  • GitHub is a popular, closed-source commercial site.

  • GitLab is a popular, open-core commercial site. Many universities have their own private GitLab servers set up.

  • Bitbucket is yet another popular commercial site.

  • Another option is NotABug.

  • There are more …

Is putting software on GitHub/GitLab/… publishing?

It is a good first step but to make your code truly findable and accessible, consider making your code citable and persistent: Get a persistent identifier (PID) such as DOI in addition to sharing the code publicly, by using services like Zenodo or similar services.