Skip to content

Commit da214be

Browse files
committed
added cloning using git command line client
1 parent 3ea9969 commit da214be

File tree

14 files changed

+129
-23
lines changed

14 files changed

+129
-23
lines changed

text/front/preface/preface.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ \chapter*{Preface}%
3737
%
3838
This book contains a lot of examples.
3939
You can find all of them in the repository \url{\programmingWithPythonCodeRepo}.
40-
You can clone this repository and play with these example codes.%
40+
You can clone this repository as discussed in \cref{sec:gettingExamples,sec:gitClone} and play with these example codes.%
4141
%
4242
\begin{sloppypar}%
4343
The text of the book itself is also available in the repository \url{\programmingWithPythonRepo}.

text/main/basics/gettingStarted/examples/examples.tex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
\hsection{Getting the Examples from this Book}%
2+
\label{sec:gettingExamples}%
23
%
34
\begin{figure}%
45
\centering%
@@ -57,7 +58,7 @@
5758
On the website, you can directly download all the examples as illustrated in \cref{fig:downloadExamples}.
5859
First, you would click on the little downward facing triangle in the button \menu{Code}.
5960
This will open a small dialog \menu{Clone} in which you can click on the \menu{Download ZIP} button.
60-
This, in turn, enters the URL~\expandafter\url{\programmingWithPythonCodeRepo/archive/refs/heads/main.zip} into your browser's download queue.
61+
This, in turn, enters the \pgls{URL}~\expandafter\url{\programmingWithPythonCodeRepo/archive/refs/heads/main.zip} into your browser's download queue.
6162
A \texttt{zip}~archive is a single file that can contain other files and folders and can be opened by the standard file managers both on \ubuntu\ and \windows.
6263
Once downloaded, the archive contains all the examples that we use in our book.%
6364
\end{sloppypar}%
@@ -75,7 +76,8 @@
7576
%
7677
Once the repository has been downloaded, \pycharm\ may ask you whether you trust this project.
7778
After making sure that you indeed downloaded the examples for this book (and if you deem this code trustworthy), you can click \menu{Trust Project}, as \cref{fig:clone04trustProject}.
78-
Finally, as \cref{fig:clone05finished} shows, you can now see and play with and run all the examples in \pycharm.%
79+
Finally, as \cref{fig:clone05finished} shows, you can now see and play with and run all the examples in \pycharm.
80+
A more comprehensive discussion on how to clone repositories is given in \cref{sec:gitClone}.%
7981
%
8082
\endhsection%
8183
%

text/main/classes/dunder/dunder.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@
12631263

12641264
As example, let us create a simple API that allows us to write output in a subset of the \acrfull{XML} format~\cite{BPSMM2008EMLX1FE,K2019ITXJY,CH2013XFCAMLTMC}.
12651265
\pgls{xml} is a format for data interchange which was predominant in distributed systems the~2000s.
1266-
After that, it began to fade out in favor~\cite{A2020XLATDOEOL} of \pgls{json}~\cite{E2017SE4TJDIS,B2017TJONJDIF} and \pgls{yaml}~\cite{DNMAASBE2021YAMLYV1,K2019ITXJY,CGTYB2022YFFDCAIE}.
1266+
After that, it began to fade out in favor~\cite{A2020XLATDOEOL} of \pgls{json}~\cite{E2017SE4TJDIS,RFC8259} and \pgls{yaml}~\cite{DNMAASBE2021YAMLYV1,K2019ITXJY,CGTYB2022YFFDCAIE}.
12671267
It is still very relevant today, for example, as foundation of several document formats such as those used in LibreOffice~\cite{DF2024LTDF,GL2012LTSOOSSCBAFACSOL} and Microsoft~Word~\cite{MS2024MW,DR2019STFAWAUMW}, or as the basis for the SVG graphics format~\cite{DDGLMSWFJJ2011SVGSSE}.
12681268
If you are a bit familiar with web design, then you will find that \pgls{xml} looks a bit like HTML~\cite{HBFLDNOP2014HAVAAAFHAX}.%
12691269
%

text/main/controlFlow/exceptions/exceptions.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@
537537
To do so, we call the built-in function~\pythonilIdx{open}.
538538
We pass in the filename~\textil{"example.txt"} as first parameter.
539539
The second parameter, \pythonil{mode}\pythonIdx{open!mode}, is set to~\pythonil{"w"}, which means \inQuotes{open for writing.}
540-
The parameter \pythonil{encoding}\pythonIdx{open!encoding} is set to~\pythonil{"UTF-8"}\pythonIdx{UTF-8}, which defines that the text should be translated to binary form when it is stored in the file via the usual \pgls{utf8}~encoding~\cite{Y2003UATFOI1,ISOIEC106462020ITUCCSU}.
540+
The parameter \pythonil{encoding}\pythonIdx{open!encoding} is set to~\pythonil{"UTF-8"}\pythonIdx{UTF-8}, which defines that the text should be translated to binary form when it is stored in the file via the usual \pgls{utf8}~encoding~\cite{RFC3629,ISOIEC106462020ITUCCSU}.
541541
This is of no importance here and we will discuss this eventually later in the book.
542542

543543
Anyway, if opening the text file succeeds, we now have a variable~\pythonil{stream_out}, which is an instance of~\pythonilIdx{IO}.

text/main/ecosystem/git/gitClone/gitClone.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
\hsection{Cloning git Repositories}%
2+
\label{sec:gitClone}%
23
%
34
The most fundamental activity you will encounter is \emph{cloning} repositories.
45
Under \git, this basically means to download the complete repository and its history to your machine.
@@ -12,5 +13,6 @@
1213
We here outline both approaches.%
1314
%
1415
\hinput{gitClonePycharm}{gitClonePycharm}%
16+
\hinput{gitCloneClient}{gitCloneClient}%
1517
%
1618
\endhsection%
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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%
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)