2020-09-29 13:53:27 +02:00
|
|
|
\chapter{GIT}
|
2020-11-13 01:35:31 +01:00
|
|
|
\index{GIT} \label{chap:GIT}
|
2020-09-29 13:53:27 +02:00
|
|
|
|
|
|
|
Git est un système de gestion de version, très bien expliqué
|
|
|
|
aux quatre coins des interwebs. Je ne vais donc pas m'étendre
|
|
|
|
plus que ça, pour passer tout de suite à un cas particulier
|
|
|
|
\footnote{que je n'arrive pas encore à vraiment maitriser}.
|
|
|
|
|
2021-03-30 10:20:21 +02:00
|
|
|
Un des premiers ancêtres connus de Git est
|
|
|
|
\textsc{sccs}\index{SCCS}.
|
|
|
|
|
2020-10-26 23:06:17 +01:00
|
|
|
% --------------------------------------------------------------------
|
2020-09-29 13:53:27 +02:00
|
|
|
\section{Démarrage}
|
|
|
|
|
2020-10-26 23:06:17 +01:00
|
|
|
\subsection{En local}
|
2020-09-29 13:53:27 +02:00
|
|
|
\begin{verbatim}
|
|
|
|
$ mkdir Foo
|
|
|
|
$ cd Foo/
|
|
|
|
$ git init
|
|
|
|
$ > README.txt
|
|
|
|
$ git add README.txt
|
|
|
|
\end{verbatim}
|
|
|
|
|
2021-04-15 22:50:39 +02:00
|
|
|
Personnellement, à ce moment, je suis perdu, et je galère souvent
|
|
|
|
avec git, désolé, je suis cablé comme ça. Alors je me soigne.
|
|
|
|
C'est pour ça que ce chapitre est incohérent, puisqu'il n'est
|
|
|
|
rempli que d'incertitudes.
|
|
|
|
|
|
|
|
% --------------------------------------------------------------------
|
|
|
|
|
2020-10-26 23:06:17 +01:00
|
|
|
\subsection{Setup du serveur}
|
2020-09-29 13:53:27 +02:00
|
|
|
|
|
|
|
Sur le serveur distant, dans un endroit accessible par
|
|
|
|
le protocole \texttt{HTTP}, il faut créer le dépot.
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
$ mkdir Foo
|
|
|
|
$ cd Foo/
|
|
|
|
$ git init --bare
|
|
|
|
\end{verbatim}
|
|
|
|
|
|
|
|
Et ensuite :
|
|
|
|
\begin{verbatim}
|
|
|
|
$ git update-server-info
|
|
|
|
\end{verbatim}
|
|
|
|
|
2020-10-26 23:06:17 +01:00
|
|
|
% --------------------------------------------------------------------
|
|
|
|
\subsection{Pousser le code}
|
2020-09-29 13:53:27 +02:00
|
|
|
|
|
|
|
Notre commit\index{commit} local semble pertinent,
|
|
|
|
il est temps de le faire connaitre au monde.
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
$ git push yuser@serveur:/chemin/vers/le/depot/Foo
|
|
|
|
\end{verbatim}
|
|
|
|
|
2020-10-26 23:06:17 +01:00
|
|
|
% --------------------------------------------------------------------
|
|
|
|
|
|
|
|
\section{Configuration dynamique}
|
|
|
|
|
|
|
|
\texttt{http://sandrotosi.blogspot.com/2020/10/multiple-git-configurations-depending.html}
|
|
|
|
|
|
|
|
One way to change the user.email git config value is to git config --local
|
|
|
|
in every repo, but that's tedious, error-prone and
|
|
|
|
doesn't scale very well with many repositories
|
|
|
|
(and the chances to forget to set the right one on a new repo are ~100\%).
|
|
|
|
|
|
|
|
The solution is to use the git-config ability to include
|
|
|
|
extra configuration files, based on the repo path, by using includeIf:
|
|
|
|
\vspace{1em}
|
|
|
|
|
|
|
|
Content of \texttt{\$HOME/.gitconfig} :
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
[user]
|
|
|
|
name = Sandro Tosi
|
|
|
|
email = <personal.address>@gmail.com
|
|
|
|
|
|
|
|
[includeIf "gitdir:~/deb/"]
|
|
|
|
path = ~/.gitconfig-deb
|
|
|
|
\end{verbatim}
|
|
|
|
|
|
|
|
Every time the git path is in ~/deb/ (which is where i have all Debian repos)
|
|
|
|
the file ~/.gitconfig-deb will be included; its content:
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
[user]
|
|
|
|
email = morph@debian.org
|
|
|
|
\end{verbatim}
|
|
|
|
|
2021-05-04 10:33:30 +02:00
|
|
|
That results in my personal address being used on all repos not part of Debian,
|
|
|
|
where i use my Debian email address. This approach can be extended to every
|
|
|
|
other git configuration values.
|
|
|
|
|
2021-04-15 22:50:39 +02:00
|
|
|
% ====================================================================
|
|
|
|
% nouvelle section 15 avril 2021 -
|
|
|
|
\section{Questions ouvertes}
|
|
|
|
|
|
|
|
Ahem\dots
|
|
|
|
|
|
|
|
Comment exclure par \textsl{.gitignore} tous les fichiers \texttt{foo.html} ?
|
|
|
|
|
|
|
|
% ====================================================================
|
2020-10-26 23:06:17 +01:00
|
|
|
|
2020-09-29 13:53:27 +02:00
|
|
|
\section{Krkrkr...}
|
|
|
|
|
|
|
|
Tout cela semble bien compliqué.
|
|
|
|
|
2021-04-15 22:50:39 +02:00
|
|
|
% ====================================================================
|
2020-09-29 13:53:27 +02:00
|
|
|
|