Git-hub

From hf.multiling
Revision as of 15:14, 24 March 2021 by Klausw@uio.no (talk | contribs) (Creating a new repository)

Jump to: navigation, search



The lab has a Github area where projects can make repositories for their code on https://github.uio.no/hf-multiling-lab

While the landing page should be readable for "everyone" with a university computer account, each repository can have their own access levels. To access the main page you need to log on once using the link hf-multiling-lab. You will then have rudimentary access to some of the repositories and can browse them and download them, but not change them. Each user will then have to contact the lab management and ask to be granted access.

Access

Each experiment has its own repository. Access could the be granted to the project as a whole or on a per experiment basis. There are two ways to grant people access, namely giving access to the user on an individual basis or by adding the user to a github team. The lab management can create a team for a project group and afterwards the group can add (or revoke) members as need be. By adding a members to a team you can have a method to consistently granting people the correct access level.


Public Experiments

The repository is also meant to be a showcase for templates or code that should be available. When creating an experiment, please consider if you can create the experiment first in a generalized manner that can be such a showcase and hiding the specialized experiment.

There is currently no method in place to make the code published on the UiO github accessible to anyone outside the university.

Private Experiments

Remember that even if an experiment is considered private and requires membership to read, the Github is still not considered suitable storage for sensitive data. Do not include logs or personal information in the repository.

Working with Git

GithubCodeButton.png

There are more tutorials about working with Git than you can shake a branch at. You can use the web page for most normal use and some of us will choose to use the command line. But for most of us, it probably helps to have a graphical user interface. On the lab github web page, you can choose to download a repository using the green button labeled Code.

As you can see from this image, you can download the repository as a zip file, but we want to download and install GitHub Desktop. Afterwards you will be asked to log in to GitHub, but that is the public GitHub and we can skip that step. Instead we choose a short name which will indicate who we are and an email address who will get the blame when someone flags our code as buggy. In the Multiling repository, it is probably a good idea to use the UiO user name and email.

Now that our github desktop application is installed, we can choose to create a new repository, add an existing repository from hard drive (also converting an existing folder to a git repository). For better documentation about how to use GitHub Desktop, please refer to the documentation: https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop

We will however address some areas of interest specific to our repository.

Creating a new repository

GitHubDesktopClone.png

If you have new code that should be moved to our repository you would need to have a repository created for you, which you can then later be assigned write permissions to. You can then choose to clone this repository using the green Code button. We want to copy the URL shown on the illustration, by clicking the clipboard icon next to the URL. Make sure that you first select https as the method. The illustration shows the URL as an SSH link, which is mainly intended for command line use. With the repository URL on the clipboard, you make your way to GitHub Desktop, select Clone a repository from the Internet and paste in the URL.

Here you will see that I have chosen to place the experiment locally on C:\Experiments\ which is where we have chosen to place them in the lab. On a regular office computer you might not have access to this location. On a regular UiO office computer (workstation, not laptop) this location would also be deemed unsafe. You will be asked for a username and password to log on. This is the University user name and password as the URL is on the University GitHub server, but please be vigilant about the server URL before you use UiO password. Once logged in, the repository is still empty. There are 0 changed files and nothing to be seen. Fetch the files using the Fetch origin tab and it still looks disappointingly empty. But you can now choose to watch the repository in Explorer or open it in an editor. This is what is explained on the center of the window and when you choose either you will see the repository has been copied over. Opening it in Explorer you can now add all your files and edit the README.md if this was made for you. As you edit files the GitHub Desktop will become colorful with *diffs* - after the old unix command, short for difference. a line with -text is text deleted and a line with +text is text added. To help visualize the deleted text is pink and the added text is green.

All the changes will be registered when you press commit to *master* in the lower left corner. This really means you are committing this text to the _branch_ called "master". The changes shown go away and you have a blank window again, with some choices. The files are not copied to GitHub unless you choose to "Push origin". Again, I recommend reading up on using Git, but these are the essentials on creating a repository.