Difference between revisions of "GitLab Service"

From radwiki
Jump to navigation Jump to search
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The GPU cluster runs a self-hosted GitLab instance. Like with the web services from GitLab.com and GitHub.com, users can pull and push code to and from remote repositories. The version control software used to do all this is called [https://git-scm.com/ Git].
+
The GPU cluster runs a self-hosted GitLab instance. Like with the web services from GitLab.com and GitHub.com, users can pull and push code to- and from remote repositories. The [https://en.wikipedia.org/wiki/Version_control version control software] used to do all this is called [https://git-scm.com/ Git]. Unlike third party remote hosting, our self-hosted instance has no storage limits and users retain full control over the privacy and teamwork settings.
 +
 
 +
If you are new to version control the concepts may have a learning curve, it is recommended to find a git tutorial/introduction and play around with it first. The following sections describe how to setup and use our Gitlab.
  
 
== Create an account ==
 
== Create an account ==
Line 7: Line 9:
  
 
== Usage ==
 
== Usage ==
 +
# install git, if you haven't already
 +
# push for your local repository/repositories to our cloud, or pull existing repos from it.
 +
 
There are two ways to push/pull files from the server:
 
There are two ways to push/pull files from the server:
* Using the '''http(s)''' protocol `https://<user>@<server>:<port>/<path_to_repo.git>`
+
* Using the '''http(s)''' protocol `https://<user>@<serverurl>:<port>/<path_to_repo.git>`
 
** or shorthand: `<server>:<user>/reponame`
 
** or shorthand: `<server>:<user>/reponame`
 
** With gitlab http, the user is your account user name. Users should be prompted for their password.
 
** With gitlab http, the user is your account user name. Users should be prompted for their password.
Line 15: Line 20:
 
** With gitlab ssh, the user is `git` and requires a pre-uploaded SSH key. No password prompt.
 
** With gitlab ssh, the user is `git` and requires a pre-uploaded SSH key. No password prompt.
  
SSH is the recommended method. Our current SSH port is 10022. HTTPS uses the default port 443 (via proxy). The server is the same as this wiki.
+
SSH is the recommended method. Our current SSH port is 10022. HTTPS uses the default port 443 (via proxy). The ssh server is the same as this wiki: hpc.radiology.hku.hk. For http the server url is hpc.radiology.hku.hk/gitlab (note the additional path in the url).
  
=== Example steps: Pushing via http ===
+
== Example ==
Create or copy a repository as with normal Git workflow, then:
+
=== Demonstation: Adding SSH key and pulling from remote ===
* `git remote add origin 147.8.193.174:9171/[username]/[reponame]`
+
{{Note|Disclaimer: do not assume the examples contain the most recent url and port information, check [[GitLab Service#Usage|Usage]] for up-to-date specs|warn}}
* `git push --set-upstream origin master`
+
[[File:Step1.png|none|thumb|Go to settings, add [[SSH Keys|SSH key]] ]]
* You will be prompted for your GitLab credentials (on Windows), if entered correctly it will push your local to the remote, creating a new remote repository if necessary. Subsequent pushes do not require credential input.
 
* If you have trouble authenticating, check if your correct user name is being used. Set it explicitly using `git remote set-url origin http://<username>@147.8.193.174:9171/<username>/<reponame>.git`
 
  
=== Example steps: Pushing with SSH key ===
+
[[File:Step2.png|none|thumb|Input your public key and save it. Your matching private key should be on your git client machine]]
* Add a public SSH key (e.g. [[SSH Keys|RSA]] type generated by `ssh-keygen`) to your GitLab profile using the web interface.
 
* Add your private key to your client git's `.ssh` folder. If it doesn't exist, create the folder. E.g. for the Windows git MSYS commandline do `cd ~/` and `mkdir .ssh`, then copy the private ssh key into it.
 
* Test the key by running `ssh -T git@147.8.193.174` from Git Bash. You should get a personalised welcome message.
 
* Now the remote add line from above becomes: `git remote add origin git@147.8.193.174:<username>/<reponame>.git`
 
`
 
  
=== Example demonstation: Adding SSH key and pulling from remote ===
+
[[File:Step7.jpg|thumb|none|Gitlab recognises my user account based on my private key, in my case this is a file called id_rsa stored in my home .ssh folder. This location may vary based on your OS and Git software configuration.]]
[[File:Step1.png|none|thumb|Go to settings, add SSH key]]
 
  
[[File:Step2.png|none|thumb|Input your public key and save it. Your matching private key should be on your git client machine]]
+
[[File:Step5.png|none|thumb|(optional step) Test the SSH connection, note the non-default port 10022. You can use the IP or URL.]]
  
 
[[File:Step3.png|none|thumb|Create a test repo in the browser]]
 
[[File:Step3.png|none|thumb|Create a test repo in the browser]]
Line 40: Line 37:
 
[[File:Step4.png|none|thumb|My new repo just has a README file]]
 
[[File:Step4.png|none|thumb|My new repo just has a README file]]
  
[[File:Step5.png|none|thumb|Test the SSH connection, note the non-default port 10022. You can use the IP or URL.]]
+
[[File:Step6.png|none|thumb|Pull the remote files with the git clone command.]]
 
 
[[File:Step6.png|none|thumb|Pull the remote files with the git clone command]]
 
  
[[File:Step7.jpg|thumb|none|Gitlab recognized my user account based on my private key, in my case this is a file called id_rsa stored in my home .ssh folder. This location may vary based on your OS and Git software configuration.]]
 
 
<br></br>
 
<br></br>
 
----
 
----
 +
 +
=== Example steps: Pushing via http ===
 +
Create or copy a repository as with normal Git workflow, then:
 +
* `git remote add origin [url]/[username]/[reponame]`
 +
* `git push --set-upstream origin master`
 +
* You will be prompted for your GitLab credentials (on Windows), if entered correctly it will push your local to the remote, creating a new remote repository if necessary. Subsequent pushes do not require credential input (configurable time window).
 +
* If you have trouble authenticating, check if your correct user name is being used (especially if you use a different name on e.g. Github). Set it explicitly using `git remote set-url origin https://<username>@<url>/<username>/<reponame>.git`
 +
 +
=== Example steps: Pushing with SSH key ===
 +
* Add a public SSH key (e.g. [[SSH Keys|RSA]] type generated by `ssh-keygen`) to your GitLab profile using the web interface.
 +
* Add your private key to your client git's `.ssh` folder. If it doesn't exist, create the folder. E.g. for the Windows git MSYS commandline do `cd ~/` and `mkdir .ssh`, then copy the private ssh key into it.
 +
* Test the key by running `ssh -T git@147.8.193.174` from Git Bash. You should get a personalised welcome message.
 +
* Now the remote add line from above becomes: `git remote add origin git@147.8.193.174:<username>/<reponame>.git`
 +
  
 
== Access Management and Sharing ==
 
== Access Management and Sharing ==

Latest revision as of 09:02, 25 July 2020

The GPU cluster runs a self-hosted GitLab instance. Like with the web services from GitLab.com and GitHub.com, users can pull and push code to- and from remote repositories. The version control software used to do all this is called Git. Unlike third party remote hosting, our self-hosted instance has no storage limits and users retain full control over the privacy and teamwork settings.

If you are new to version control the concepts may have a learning curve, it is recommended to find a git tutorial/introduction and play around with it first. The following sections describe how to setup and use our Gitlab.

Create an account

Using a web browser, access the GitLab page, then create an account following the on-screen instructions.

The web interface of Gitlab is heavy with javascript, so the initial visit (i.e. pre-caching) may be slow on mobile connections

Usage

  1. install git, if you haven't already
  2. push for your local repository/repositories to our cloud, or pull existing repos from it.

There are two ways to push/pull files from the server:

  • Using the http(s) protocol https://<user>@<serverurl>:<port>/<path_to_repo.git>
    • or shorthand: <server>:<user>/reponame
    • With gitlab http, the user is your account user name. Users should be prompted for their password.
  • Using the ssh protocol ssh://<user>@<server>:<port>/<path_to_repo.git>
    • or tcp shorthand: <user>@<server>:<accountname>/<reponame.git>
    • With gitlab ssh, the user is git and requires a pre-uploaded SSH key. No password prompt.

SSH is the recommended method. Our current SSH port is 10022. HTTPS uses the default port 443 (via proxy). The ssh server is the same as this wiki: hpc.radiology.hku.hk. For http the server url is hpc.radiology.hku.hk/gitlab (note the additional path in the url).

Example

Demonstation: Adding SSH key and pulling from remote

Disclaimer: do not assume the examples contain the most recent url and port information, check Usage for up-to-date specs
Go to settings, add SSH key
Input your public key and save it. Your matching private key should be on your git client machine
Gitlab recognises my user account based on my private key, in my case this is a file called id_rsa stored in my home .ssh folder. This location may vary based on your OS and Git software configuration.
(optional step) Test the SSH connection, note the non-default port 10022. You can use the IP or URL.
Create a test repo in the browser
My new repo just has a README file
Pull the remote files with the git clone command.




Example steps: Pushing via http

Create or copy a repository as with normal Git workflow, then:

  • git remote add origin [url]/[username]/[reponame]
  • git push --set-upstream origin master
  • You will be prompted for your GitLab credentials (on Windows), if entered correctly it will push your local to the remote, creating a new remote repository if necessary. Subsequent pushes do not require credential input (configurable time window).
  • If you have trouble authenticating, check if your correct user name is being used (especially if you use a different name on e.g. Github). Set it explicitly using git remote set-url origin https://<username>@<url>/<username>/<reponame>.git

Example steps: Pushing with SSH key

  • Add a public SSH key (e.g. RSA type generated by ssh-keygen) to your GitLab profile using the web interface.
  • Add your private key to your client git's .ssh folder. If it doesn't exist, create the folder. E.g. for the Windows git MSYS commandline do cd ~/ and mkdir .ssh, then copy the private ssh key into it.
  • Test the key by running ssh -T git@147.8.193.174 from Git Bash. You should get a personalised welcome message.
  • Now the remote add line from above becomes: git remote add origin git@147.8.193.174:<username>/<reponame>.git


Access Management and Sharing

You can set repositories to private and invite users with different permission levels. You can invite either individually or in bulk via a Group.

Alternatively, you can move your repository to a Group namespace (e.g. Radiology), in which case member access depends on their Group Role. Depending on your own role in that Group, you may lose some admin-related rights for the repository.

If you are not part of a (private) Group, request with a Group Owner to be added. For public Groups you can use the GitLab "explore groups" feature to make a request.