remotes_handouts.tex 4.05 KB
Newer Older
1 2
\documentclass{article}

3
\providecommand{\handoutsTitle}{Git and remote repositories}
4

5
\usepackage{handouts}
6 7 8 9 10 11

\usepackage{multicol}
\usepackage{enumitem}
\usepackage{xcolor}
\usepackage{graphicx}

12
\input{../shared/shared}
13

14 15
\begin{document}
\makeHeader
16

17
\subsubsection*{Some notes about using GitLab}
18 19 20 21 22 23 24
Please take the following into account with respect to our GitLab server:
\begin{itemize}
  \item You can login to GitLab using your LUMC account.
  \item If you don't have an LUMC account, ask us to create a GitLab account
    for you and select {\em Standard} instead of {\em LDAP} on the login
    page.
\end{itemize}
Mihai's avatar
Mihai committed
25

26 27
It is convenient to set up an ssh key on GitLab. Make one as follows (you can
leave all fields blank):
Mihai's avatar
Mihai committed
28 29 30 31 32 33 34 35 36 37 38
\begin{lstlisting}
  $ ssh-keygen
  Enter file in which to save the key (/home/<username>/.ssh/id_rsa):
  Enter passphrase (empty for no passphrase):
  Enter same passphrase again:
\end{lstlisting}
\medskip

Open \url{https://git.lumc.nl} in your browser and log in.
\medskip

39 40
Click on your avatar (top-right corner), choose ``Settings'', and then go the
``SSH Keys'' page.
Mihai's avatar
Mihai committed
41 42
\medskip

43 44
Copy your ssh key, retrieved with the following \lstinline{cat} command, and
paste it in the ``Key'' field:
Mihai's avatar
Mihai committed
45 46 47 48 49
\begin{lstlisting}
  $ cat ~/.ssh/id_rsa.pub
\end{lstlisting}
\medskip

50 51
Give your key a title (e.g., ``Course machine'') and press the ``Add key''
button.
52 53
\bigskip

54
\subsubsection*{Add your repository to GitLab}
Martijn Vermaat's avatar
Martijn Vermaat committed
55 56 57 58 59
\begin{quote}
(If you don't have a repository on your local machine from the previous
practical, create one now with at least one commit.)
\end{quote}

60 61 62
Now you have a nice repository, of course you want to share it on GitLab.
\bigskip

63
Go to GitLab (\url{https://git.lumc.nl}) and create a new project (use the
Martijn Vermaat's avatar
Martijn Vermaat committed
64
same name you used to store your repository locally).
65 66

\begin{itemize}
67
  \item \emph{Question:} What is the repository URL for your new project?
68 69 70
\end{itemize}
\bigskip

71
Add the GitLab repository as a remote to your local repository.
72 73
\bigskip

Martijn Vermaat's avatar
Martijn Vermaat committed
74
Push your commits to GitLab.
75 76

\begin{itemize}
77 78
  \item \emph{Question:} Can you see your repository content in the GitLab web
    interface?
79
\end{itemize}
80
\bigskip
81

82 83
\emph{Hint:} Use \lstinline{git push} once with the \lstinline{-u} flag so you
can use the \lstinline{git push} / \lstinline{git pull} shortcuts.
84 85
\bigskip

86
\subsubsection*{More synchronisation}
Martijn Vermaat's avatar
Martijn Vermaat committed
87 88
Look for a way to edit a file directly from the GitLab web interface (in your
browser) and do this at least once.
89 90
\bigskip

Martijn Vermaat's avatar
Martijn Vermaat committed
91 92
Update your local copy of the file with the change you just made (by fetching
and merging).
93 94
\bigskip

Martijn Vermaat's avatar
Martijn Vermaat committed
95 96 97
Now make another commit locally and push it to the GitLab server. Verify that
all these changes are now present both on your local machine and on the GitLab
server.
98

99
\subsubsection*{Collaboration}
100 101
In this practical, you'll work with both your repository and with the
repository your neighbour created
102
during the previous practical. We'll refer to this repository as {\bf N}, and
103 104
to your own repository from the previous practical as {\bf Y}. Note that by now
both repositories should have a
105 106 107
corresponding GitLab project (a remote repository).
\bigskip

108 109
Make sure that your GitLab project \textbf{Y} is private and add your colleague
as a member to it as \textbf{Guest}.
110 111
\bigskip

112 113
Try to \textbf{clone} his or her repository to your local machine. Make sure to
do this in a separate directory.
114 115 116 117 118

\begin{itemize}
  \item \emph{Question:} Was the cloning successful? Try to identify why.
\end{itemize}

119 120 121
Change the role of your neighbour from \textbf{Guest} to \textbf{Developer} and
try to \textbf{clone} his repository again once your neighbour made you a
\textbf{Developer}.
122 123
\bigskip

124 125
Edit locally a file from your neighbour \textbf{N} directory, stage it, commit
it, and try to \textbf{push}.
126 127 128 129 130

\begin{itemize}
  \item \emph{Question:} Were you able to push? Try to identify why.
\end{itemize}

131 132
Change your neighbour's role in your GitLab project from \textbf{Developer} to
\textbf{Maintainer}.
133 134
\bigskip

135 136
After your neighbour upgraded your role to \textbf{Maintainer} try to push
again your changes to his GitLab repository.
137 138 139 140
\medskip

Inspect the commit graph on GitLab.

141
\end{document}