Skip to content

Sharing your project

Suppose now that you have a local Git repository that you want to share with the world (or selected people). In principle, you could set up a server on your local machine and give access to your Git repository right there. This would be quite advanced computer administration work. A much easier way is to set up an account on a web platform dedicated to hosting Git projects. The largest provider of such service is Github. If you are interested in your code having as much visibility as possible, this is where you should put it.

The computing center of IN2P3, a division of CNRS, also offers hosting of Git projects. It uses software called Gitlab to manage the hosting. The adress of the hosting site is https://gitlab.in2p3.fr. It is open to members of all academic institutions in France. As Gitlab is quite complex software to maintain, the IN2P3 Gitlab site is de facto one of the main Git hosting site for the French academic community. For example, the administrators of the IPSL computing center have decided it was not worth setting up a Gitlab instance in IPSL and they point IPSL members to the Gitlab of IN2P3. If you have legal concerns about putting your code on Github, you can put it on the IN2P3 Gitlab. Also, for advanced Git users, you have access to more functionality (like protected branches for example) on the IN2P3 Gitlab than with a free account on Github. (You can get as much functionality on Github but with a paying account.)

Another good hosting site is Codeberg. This is a good choice if you are inclined to favor a non-profit, community-led organization, without tracking. It is also useful if you cannot use the Gitlab instance of IN2P3 because you are not a member of the French academic community.

An easy way to share your repository on a web platform (Github, Gitlab, Codeberg, etc.) is to create first an empty repository with the web interface. Do not choose "import a repository", do not associate yet a licence file nor a README file. The web interface will tell you at what address your empty repository has been created. Then go to your local Git directory and tell it that it is associated to the remote repository. Assuming your have created a public repository on the web platform, we can read from it with the https protocol and write to it with the git protocol:

git remote add origin https://github.com/my_id/myproject.git
git remote set-url --push origin git@github.com:my_id/myproject.git

The https protocol for read access is convenient because it does not require login. The git protocol for write access conveniently uses ssh login.

Then you can send the content of your local repository to the remote repository with the command:

git push
And you use this command again every time you want to update the remote repository.

It is convenient to create the LICENSE file with the web interface, rather than locally, because the web platform has all the possible LICENSE files, you can choose one from a menu. You will have to update your local repository afterwards with git pull (see Using someone else's project).

Do not forget to create and a README file (you can do that locally and push the commit).

Important note. We have seen that it is possible to rewrite history. Do not change commits that have been pushed! The corollary is: do not push your work until you are happy with it!