|
| 1 | +\hsection{Cloning git Repositories with the git Client}% |
| 2 | +% |
| 3 | +\begin{figure}% |
| 4 | +\centering% |
| 5 | +% |
| 6 | +\subfloat[][% |
| 7 | +After opening the \ubuntu\ \linux\ \pgls{terminal} using \ubuntuTerminal, we enter the directory into which we want to download the repository. % |
| 8 | +We then type the command \bashil{git clone https://github.com/thomasWeise/databasesCode} and hit \keys{\enter}. % |
| 9 | +The option \bashil{--recurse-submodules} can be added just in case.% |
| 10 | +\label{fig:gitCloneClient1clone}% |
| 11 | +]{\includegraphics[width=0.78\linewidth]{\currentDir/gitCloneClient1clone}}% |
| 12 | +% |
| 13 | +\floatRowSep% |
| 14 | +% |
| 15 | +\subfloat[][% |
| 16 | +The process of cloning the repository begins.% |
| 17 | +\label{fig:gitCloneClient2cloning}% |
| 18 | +]{\includegraphics[width=0.78\linewidth]{\currentDir/gitCloneClient2cloning}}% |
| 19 | +% |
| 20 | +\floatRowSep% |
| 21 | +% |
| 22 | +\subfloat[][% |
| 23 | +Sometimes, there may be connectivity issues. % |
| 24 | +But do not fret if that happens\dots% |
| 25 | +\label{fig:gitCloneClient3error}% |
| 26 | +]{\includegraphics[width=0.78\linewidth]{\currentDir/gitCloneClient3error}}% |
| 27 | +% |
| 28 | +\floatRowSep% |
| 29 | +% |
| 30 | +\subfloat[][% |
| 31 | +{\dots}simply try again (and, if necessary, again and again). % |
| 32 | +Sometimes, it may make sense to switch the network, e.g., from using WLAN, instead connect your mobile phone to your computer using a USB cable and share the data connection of the mobile phone using USB tethering.% |
| 33 | +\label{fig:gitCloneClient4nextAttempt}% |
| 34 | +]{\includegraphics[width=0.78\linewidth]{\currentDir/gitCloneClient4nextAttempt}}% |
| 35 | +% |
| 36 | +\floatRowSep% |
| 37 | +% |
| 38 | +\subfloat[][% |
| 39 | +Eventually, it will work.% |
| 40 | +\label{fig:gitCloneClient5success}% |
| 41 | +]{\includegraphics[width=0.78\linewidth]{\currentDir/gitCloneClient5success}}% |
| 42 | +% |
| 43 | +\floatRowSep% |
| 44 | +% |
| 45 | +\subfloat[][% |
| 46 | +The repository has been downloaded and a new folder with the repository name (here:~\textil{databasesCode}) has appeared.% |
| 47 | +\label{fig:gitCloneClient6files}% |
| 48 | +]{\includegraphics[width=0.78\linewidth]{\currentDir/gitCloneClient6files}}% |
| 49 | +% |
| 50 | +\caption{Cloning a \git\ repository using the \git\ \pgls{client} application \bashil{git} in an \ubuntu\ \linux\ \pgls{terminal} and how to deal with connection errors.}% |
| 51 | +\label{fig:gitCloneClient}% |
| 52 | +% |
| 53 | +\end{figure}% |
| 54 | +% |
| 55 | +The most basic way to clone \git\ repositories is to use the \git\ \pgls{client} application. |
| 56 | +This is a command line tool that can be executed in a \pgls{terminal}. |
| 57 | +Here, we simply assume that you already have it installed the \git\ \pgls{client} program~\bashil{git}. |
| 58 | + |
| 59 | +In \cref{fig:gitCloneClient}, we illustrate how the \git\ \pgls{client} program is used under \ubuntu\ \linux. |
| 60 | +Under Microsoft \windows, it will work analogously. |
| 61 | +First, we need to open a \pgls{terminal} window. |
| 62 | +Under \ubuntu\ \linux, we therefore press \ubuntuTerminal. |
| 63 | +Under \windows, we instead \windowsTerminal. |
| 64 | +We then enter the directory into which we want to download the repository using~\bashil{cd}. |
| 65 | +Notice that if we download a repository with the name~\textil{abc}, this will create a new directory named~\textil{abc} inside that current working directory. |
| 66 | + |
| 67 | +We then type the command \bashil{git clone https://github.com/thomasWeise/databasesCode} and hit \keys{\enter}. |
| 68 | +Sometimes, repositories contain submodules. |
| 69 | +A submodules is basically a links to a specific state (commit) of \emph{another} repository. |
| 70 | +The files of the referenced commit of the other repository would then exist inside a directory of the repository that we want to clone. |
| 71 | +If we want to have a full copy of all the files, including the files referenced this way, we need to add the option \bashil{--recurse-submodules} to the \bashil{git} command. |
| 72 | +We do this in \cref{fig:gitCloneClient1clone} to be on the safe side for demonstration purpose (although the repository \textil{databasesCode} does \emph{not} have any submodule). |
| 73 | + |
| 74 | +After we hit \keys{\enter}, the process of cloning the repository begins in \cref{fig:gitCloneClient2cloning}. |
| 75 | +Sadly, when we clone repositories using \pgls{HTTPS} \pglspl{URL} from \github, sometimes, there may be connectivity issues. |
| 76 | +I noticed that using the \pgls{SSH} \pglspl{URL} is much more reliable. |
| 77 | +An example for such an error is shown in \cref{fig:gitCloneClient3error}. |
| 78 | + |
| 79 | +However, this is not a big problem. |
| 80 | +If such errors happen, you can simply try again after some time. |
| 81 | +I furthermore noticed that, often, changing your internet connection can solve the problem. |
| 82 | +Let's say that you are trying to clone the repository using your wired or wireless LAN and it does not work. |
| 83 | +Then it often helps to first switch of the network connection on your computer. |
| 84 | +On your mobile phone, you should also switch off wireless LAN and instead activate your mobile data connection. |
| 85 | +Then you can connect your mobile phone to your computer using a USB cable and select \emph{USB tethering} on your phone. |
| 86 | +This will share the mobile data connection with your computer. |
| 87 | +Then, simply try to clone the repository again, as shown in \cref{fig:gitCloneClient4nextAttempt}. |
| 88 | +The connection switching is just a quick work around. |
| 89 | +Often, \bashil{git clone} works at first attempt and, if not, works after you wait a minute or so. |
| 90 | + |
| 91 | +Eventually, it will work, as shown in \cref{fig:gitCloneClient5success}. |
| 92 | +After the \bashil{git} command completes, the repository has been downloaded and a new folder with the repository name (here:~\textil{databasesCode}) has appeared. |
| 93 | +The \bash\ command \bashil{ls} lists the files in a directory. |
| 94 | +We see that the new directory contains the downloaded files in \cref{fig:gitCloneClient6files}. |
| 95 | +Here, we will not deal with the issue of \pglspl{virtualEnvironment}, as we discussed them in the previous section about cloning repositories using \pycharm.% |
| 96 | +% |
| 97 | +\FloatBarrier% |
| 98 | +\endhsection% |
0 commit comments