diff --git a/basics/basics_handouts.tex b/basics/basics_handouts.tex index d039cf34df31d1196b8d37184908b9134796bd46..be15cdcc92c809d55d9a8fd608c33ccc0cb8128d 100644 --- a/basics/basics_handouts.tex +++ b/basics/basics_handouts.tex @@ -17,6 +17,8 @@ Git Basics practical. First, create an empty directory and use ``\texttt{git init}'' to make a new repository. \begin{itemize} + \item \emph{Hint:} Use a unique name for the directory, different from your + neighbour (this is convenient later). \item \emph{Question:} How can you see that you are working in a Git repository? \end{itemize} diff --git a/merging/merging_handouts.tex b/merging/merging_handouts.tex index 8dfaedf9f8f4be0535398b135dd9ec76348354e8..5a2df65f3cb85884237afec7081dcb1252b7f8f1 100644 --- a/merging/merging_handouts.tex +++ b/merging/merging_handouts.tex @@ -9,65 +9,53 @@ \begin{center} {\bf Git Introduction Course} -Working with branches in Git practical. +Combining changes by merging practical. \end{center} \bigskip -\subsubsection*{Inspect the commit graph.} -We'll work from the repository you created in the previous practical. - -\begin{itemize} - \item \emph{Question:} What is your current branch and what is the hash of - the commit it points to? - \item \emph{Question:} What does the commit graph of you repository look - like? Can you draw it on paper? -\end{itemize} -\emph{Hint:} Use \texttt{git log} with the appropriate arguments. +\subsubsection*{Setting the stage.} +In this practical, you'll work with the repository your neighbour created +during the previous practical. We'll refer to this repository as {\bf N}, and +to your own repository from the previous practical as {\bf Y}. \bigskip -As an alternative to \texttt{git log}, you can also try a graphical viewer -such as \texttt{gitg} (installed on the course laptops) or \texttt{gitk}. +Clone his or her repository to your local machine. Make sure to do this in a +separate directory. \bigskip -\subsubsection*{Implement a feature in a new branch.} -Let's do some real work (e.g., add some documentation to the project). +After you and your neighbour both cloned eachother's repositories: +\begin{enumerate} + \item Add a new commit to repository {\bf Y} on GitLab (so the one your + neighbour just cloned). + \item Wait for eachother before continuing. + \item Update your clone of {\bf N} with \texttt{git fetch}. +\end{enumerate} \bigskip -Start by creating a branch for your work (give it a descriptive name) and -switch to it. - -\begin{itemize} - \item \emph{Question:} What branches are there now and what are the commits - they point to? -\end{itemize} +\emph{Question:} What does the commit graph of your repository look + like? Can you draw it on paper? \bigskip -Implement your feature (e.g. write documentation) and commit your changes. - -\begin{itemize} - \item \emph{Question:} What does the commit graph of you repository look - like now? -\end{itemize} +\emph{Hint:} Use \texttt{git log} with the appropriate arguments. \bigskip -\subsubsection*{Merge your feature.} -Of course we want this nice feature in our \texttt{master} branch. +As an alternative to \texttt{git log}, you can also try a graphical viewer +such as \texttt{gitg} (installed on the course laptops) or \texttt{gitk}. \bigskip -\begin{itemize} - \item \emph{Question:} If you want to merge branch \texttt{B} into branch - \texttt{A}, what should be your current branch? -\end{itemize} +\subsubsection*{Fast-forward merging.} +Of course we want the nice commit your neighbour just made in our +\texttt{master} branch. \bigskip -Merge your feature branch into \texttt{master}. +Merge the remote \texttt{master} branch into \texttt{master}. \begin{itemize} \item \emph{Question:} What does the commit graph of you repository look @@ -76,13 +64,8 @@ Merge your feature branch into \texttt{master}. \bigskip -Since you merged it, you can now delete the feature branch. - -\bigskip - \subsubsection*{A three-way merge.} -Unless you were extremely zealous, the last section produced a fast-forward -merge. +The previous section produced a fast-forward merge. \bigskip @@ -92,12 +75,20 @@ merge. \bigskip -Manipulate your repository in such a way that the commit graph contains a -merge commit (created by a three-way merge). +Together with your neighbour, manipulate your repository in such a way that +the commit graph contains a merge commit (created by a three-way merge). \begin{itemize} \item \emph{Question:} What does the commit graph of you repository look like now? \end{itemize} +\bigskip + +\subsubsection*{Resolving a merge conflict.} +Now do the same thing again (a three-way merge), but in such a way the merge +step will result in a merge conflict. Resolve the conflict in a way you feel +is appropriate. + + \end{document} diff --git a/remotes/remotes_handouts.tex b/remotes/remotes_handouts.tex index fa3ff524c0c22af7d010eaa10aa574800c8c3cfc..6baac8235ed1f052154513826cb51c73a087d0cf 100644 --- a/remotes/remotes_handouts.tex +++ b/remotes/remotes_handouts.tex @@ -20,10 +20,6 @@ Please take the following into account with respect to our GitLab server: \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. - \item Due to the LUMC firewall, accessing repositories using SSH is only - possible from the LUMC network (and not from the LUMC gast network). As an - alternative, you can always use HTTPS but the downside is that you have to - keep repeating your password. \item Our GitLab server is very similar (in fact, it is a clone) to the popular online GitHub (\texttt{https://github.com}) and Bitbucket (\texttt{https://bitbucket.org}) services. @@ -32,11 +28,17 @@ Please take the following into account with respect to our GitLab server: \bigskip \subsubsection*{Add your repository to GitLab.} +\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} + Now you have a nice repository, of course you want to share it on GitLab. \bigskip -Go to GitLab (\texttt{https://git.lumc.nl}) and create a new project. +Go to GitLab (\texttt{https://git.lumc.nl}) and create a new project (use the +same name you used to store your repository locally). \begin{itemize} \item \emph{Question:} What is the repository URL for your new project? @@ -48,7 +50,7 @@ Add the GitLab repository as a remote to your local repository. \bigskip -Push your branch(es) to GitLab. +Push your commits to GitLab. \begin{itemize} \item \emph{Question:} Can you see your repository content in the GitLab web @@ -57,54 +59,25 @@ Push your branch(es) to GitLab. \bigskip -\subsubsection*{Clone an existing repository from GitLab.} -There already are some nice repositories on GitLab! Pick one (e.g., from the -person sitting next to you, or browse the public repositories using the globe -icon in the top right). - -\bigskip - -Create a local clone of the repository you picked. - -\begin{itemize} - \item \emph{Question:} In the resulting repository, what remotes and - branches exist? -\end{itemize} - -\bigskip - -\subsubsection*{Create a merge request.} -If you are interested, here are some additional GitLab features you can -use. Fork an existing project, implement a feature, and submit a merge -request. +\emph{Hint:} Use \texttt{git push} once with the \texttt{-u} flag so you can +use the \texttt{git push/pull} shortcuts. \bigskip -Find an interesting project and click the \emph{Fork} button. This makes a -copy of the project under your own user, on GitLab. +\subsubsection*{More synchronisation.} +Look for a way to edit a file directly from the GitLab web interface (in your +browser) and do this at least once. \bigskip -Clone the project (your fork) to your local machine. +Update your local copy of the file with the change you just made (by fetching +and merging). \bigskip -Create a new branch and implement some feature in it. Make sure to commit -this. - -\bigskip - -Push your new branch to GitLab (your fork of the project). - -\bigskip - -If you now go to your GitLab dashboard (homepage), you'll see a green button -to create a merge request. From the merge request, the owner of the original -project can directly merge your changes using only the web interface. - -\bigskip +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. -\emph{Hint:} You can also start a discussion or do some code review inside the -merge request. \end{document}