Skip to content

Commit 1a0d00a

Browse files
committed
Describe .gitattributes
1 parent 0c58204 commit 1a0d00a

File tree

2 files changed

+74
-128
lines changed

2 files changed

+74
-128
lines changed

.gitattributes

Lines changed: 5 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,5 @@
1-
# Common settings that generally should always be used with your language specific settings
2-
3-
# Auto detect text files and perform LF normalization
4-
# https://www.davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
5-
* text=auto
6-
7-
#
8-
# The above will handle all files NOT found below
9-
#
10-
11-
# Documents
12-
*.bibtex text diff=bibtex
13-
*.doc diff=astextplain
14-
*.DOC diff=astextplain
15-
*.docx diff=astextplain
16-
*.DOCX diff=astextplain
17-
*.dot diff=astextplain
18-
*.DOT diff=astextplain
19-
*.pdf diff=astextplain
20-
*.PDF diff=astextplain
21-
*.rtf diff=astextplain
22-
*.RTF diff=astextplain
23-
*.md text
24-
*.tex text diff=tex
25-
*.adoc text
26-
*.textile text
27-
*.mustache text
28-
*.csv text
29-
*.tab text
30-
*.tsv text
31-
*.txt text
32-
*.sql text
33-
34-
# Graphics
35-
*.png binary
36-
*.jpg binary
37-
*.jpeg binary
38-
*.gif binary
39-
*.tif binary
40-
*.tiff binary
41-
*.ico binary
42-
# SVG treated as an asset (binary) by default.
43-
*.svg text
44-
# If you want to treat it as binary,
45-
# use the following line instead.
46-
# *.svg binary
47-
*.eps binary
48-
49-
# Scripts
50-
*.bash text eol=lf
51-
*.fish text eol=lf
52-
*.sh text eol=lf
53-
# These are explicitly windows files and should use crlf
54-
*.bat text eol=crlf
55-
*.cmd text eol=crlf
56-
*.ps1 text eol=crlf
57-
58-
# Serialisation
59-
*.json text
60-
*.toml text
61-
*.xml text
62-
*.yaml text
63-
*.yml text
64-
65-
# Archives
66-
*.7z binary
67-
*.gz binary
68-
*.tar binary
69-
*.tgz binary
70-
*.zip binary
71-
72-
# Text files where line endings should be preserved
73-
*.patch -text
74-
75-
#
76-
# Exclude files from exporting
77-
#
78-
79-
.gitattributes export-ignore
80-
.gitignore export-ignore
1+
# Very simple .gitattributes working well in most projects
2+
* text=auto eol=lf
3+
*.[cC][mM][dD] text eol=crlf
4+
*.[bB][aA][tT] text eol=crlf
5+
*.[pP][sS]1 text eol=crlf

slides/04 - dvcs-1/04-git-intro.tex

Lines changed: 69 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
%\documentclass[12pt,handout]{beamer}
22
\documentclass[xcolor=dvipsnames,presentation]{beamer}
33
\usepackage{../oop-slides-lab}
4+
\usepackage{fancyvrb}
45

56
\setbeamertemplate{bibliography item}[text]
67

@@ -159,48 +160,31 @@ \subsection{Operazioni preliminari}
159160
capire chi ha apportato modifiche).
160161
}
161162
\bl{In Git}{
162-
È possibile specificare un nome utente di default utilizzando
163+
Si specifica un nome utente di default utilizzando
163164
\iz {
164165
\item \texttt{git config --global user.name "YOUR NAME"}
165166
\begin{itemize}
166167
\item \textbf{OVVIAMENTE} al posto di \texttt{YOUR NAME} dovrete inserire il vostro nome.
167168
\item \textbf{Configurate il vostro vero nome, non un nickname!}
169+
\begin{itemize}
170+
\item In fase di correzione del progetto usiamo (anche) git per capire chi ha fatto cosa,
171+
e vedere roba firmata da \texttt{superkikk4z} e \texttt{TheDarkDestructor} non è che sia proprio bello
172+
(oltre al fatto che rischiamo di sbagliare l'assegnamento nome-persona)
173+
\item Se siete in lab importa poco, ma meglio far le cose bene fin da subito
174+
\item Il nickname fantasioso potrete usarlo su GitHub prossimamente,
175+
lo usiamo anche noi (\texttt{DanySK}, \texttt{metaphori}...)
176+
\end{itemize}
168177
\end{itemize}
169178
}
170-
È possibile specificare una email di default utilizzando
179+
L'email di default is setta con
171180
\iz {
172181
\item \texttt{git config --global user.email "your.email@provider"}
173182
}
174183
}
175-
\bl{Caratteri di newline}{
176-
\begin{itemize}
177-
\item Git prova ad essere ``smart'' nella configurazione dei caratteri che rappresentano
178-
una nuova linea di testo, che differiscono per piattaforma
179-
\begin{itemize}
180-
\item Come spesso capita, nel tentativo di essere smart fa più danno che utile.
181-
\end{itemize}
182-
\item Noi useremo una precisa configurazione di Eclipse
183-
\item Vogliamo che i nostri file abbiano un terminatore preciso, e vogliamo che tutti i
184-
membri del team lo usino correttamente
185-
\begin{itemize}
186-
\item Evitando di fare mega-salvataggi solo perché cambiano i caratteri di fine
187-
linea
188-
\end{itemize}
189-
\item Linux e MacOS: usa il carattere presente nel testo
190-
\begin{itemize}
191-
\item \texttt{git config --global core.autocrlf input}
192-
\end{itemize}
193-
\item Windows: disattiva la conversione automatica a CRLF
194-
\begin{itemize}
195-
\item \texttt{git config --global core.autocrlf false}
196-
\end{itemize}
197-
\end{itemize}
198-
}
199184
\begin{block}{Esercizio}
200185
\begin{itemize}
201186
\item Si apra un terminale
202187
\item Si settino username ed email di default usando nome e cognome ed email istituzionale
203-
\item Si disabiliti la funzione autocrlf
204188
\end{itemize}
205189
\end{block}
206190
\end{frame}
@@ -572,6 +556,53 @@ \subsection{Operazioni di base sul repository}
572556

573557
\subsection{Gestione dei file}
574558

559+
\begin{frame}[allowframebreaks,fragile]{Ignorare file indesiderati}
560+
\begin{block}{Gestione dei caratteri di newline}
561+
\begin{itemize}
562+
\item Git prova ad essere ``smart'' nella configurazione dei caratteri che rappresentano una nuova linea di testo, che differiscono per piattaforma
563+
\begin{itemize}
564+
\item Come spesso capita, nel tentativo di essere smart si fallisce clamorosamente.
565+
\end{itemize}
566+
\item È meglio configurare Git per gestire correttamente i file di linea, specie se il team lavora con OS diversi!
567+
\begin{itemize}
568+
\item Evitando di fare mega-commit solo perché cambiano i caratteri di fine linea
569+
\end{itemize}
570+
\end{itemize}
571+
\end{block}
572+
\begin{block}{Gestione dei caratteri di newline}
573+
\begin{itemize}
574+
\item Configuriamo Git per usare il fine linea Unix, eccetto che sugli script Windows-specifici
575+
\item Ci sono vari modi, il più portabile è la creazione di un file \texttt{.gitattributes} nella radice del repository
576+
\begin{itemize}
577+
\item È possibile specificare quali tipi di file sono testuali, e quali convenzioni usare
578+
\item È bene che il file \texttt{.gitattributes} venga aggiunto al tracker!
579+
\item Nota: il file si chiama \textbf{esattamente} \texttt{.gitattributes},
580+
\textbf{non} \texttt{ALTRO.gitattributes}, \texttt{.gitattributes.txt}, \texttt{gitattributes.gitattributes}, o altre stravaganti forme.
581+
\end{itemize}
582+
\end{itemize}
583+
\end{block}
584+
\begin{block}{Contenuto del file \texttt{.gitattributes}}
585+
\VerbatimInput{../../.gitattributes}
586+
\end{block}
587+
\begin{block}{Esercizio}
588+
\begin{itemize}
589+
\item Si crei il file .gitattributes
590+
\begin{itemize}
591+
\item Può essere scaricato da \url{https://bit.ly/oop-gitattributes}
592+
\item Per chi ha una shell Unix:
593+
\begin{itemize}
594+
\item {\scriptsize \texttt{curl -L -o ".gitattributes" "https://bit.ly/oop-gitattributes"}}
595+
\end{itemize}
596+
\end{itemize}
597+
\item Si osservi lo stato del repository
598+
\item Si aggiunga \texttt{.gitattributes} alla staging area
599+
\item Si osservi lo stato del repository
600+
\item Si effettui il commit
601+
\item Si osservi lo stato del repository
602+
\end{itemize}
603+
\end{block}
604+
\end{frame}
605+
575606
\begin{frame}[allowframebreaks,fragile]{Ignorare file indesiderati}
576607
\begin{block}{In generale}
577608
In molti casi, vorremmo poter dire al DVCS di ignorare alcuni file o cartelle, che sappiamo
@@ -586,9 +617,8 @@ \subsection{Gestione dei file}
586617
\begin{itemize}
587618
\item I file elencati dentro \texttt{.gitignore} saranno invisibili a Git
588619
\item È bene che il file \texttt{.gitignore} venga aggiunto al tracker!
589-
\item Nota: il file si chiama \textbf{esattamente} \texttt{.gitignore}, \textbf{non}
590-
\texttt{ALTRO.gitignore}, \texttt{.gitignore.txt}, \texttt{gitignore.gitignore}, o altre stravaganti
591-
forme.
620+
\item Nota: il file si chiama \textbf{esattamente} \texttt{.gitignore},
621+
\textbf{non} \texttt{ALTRO.gitignore}, \texttt{.gitignore.txt}, \texttt{gitignore.gitignore}, o altre stravaganti forme.
592622
\end{itemize}
593623
\end{block}
594624
\begin{block}{Sintassi di .gitignore}
@@ -614,20 +644,16 @@ \subsection{Gestione dei file}
614644
\end{block}
615645
\begin{block}{Note sulla creazione di file il cui nome inizia per \texttt{.}}
616646
\begin{itemize}
617-
\item Windows ha l'abitudine di aggiungere autonomamente l'estensione ai file che
618-
vengono creati...
647+
\item Windows ha l'abitudine di aggiungere autonomamente l'estensione ai file che vengono creati...
619648
\item ...per poi nasconderla
620-
\item Verificate \textbf{sempre con il terminale} che il file sia esattamente quello che
621-
vi aspettate, ossia \texttt{.gitignore}
622-
\item Se il file viene chiamato \texttt{.gitignore.txt}, o in qualunque modo diverso da
623-
\texttt{.gitignore}, non sarà considerato un ignore file valido da Git!
649+
\item Verificate \textbf{sempre con il terminale} che il file sia esattamente quello che vi aspettate, ossia \texttt{.gitignore}
650+
\item Se il file viene chiamato \texttt{.gitignore.txt}, o in qualunque modo diverso da \texttt{.gitignore}, non sarà considerato un ignore file valido da Git!
624651
\end{itemize}
625652
Il problema non si pone su MacOS X e Linux.
626653
\end{block}
627654
\begin{block}{Creare il file da terminale}
628655
\begin{itemize}
629-
\item È conveniente usare direttamente il terminale per creare il file
630-
\texttt{.gitignore}
656+
\item È conveniente usare direttamente il terminale per creare il file \texttt{.gitignore}
631657
\item \texttt{echo > .gitignore}
632658
\begin{itemize}
633659
\item Crea un file di nome \texttt{.gitignore} contenente solo una newline
@@ -636,13 +662,10 @@ \subsection{Gestione dei file}
636662
\end{itemize}
637663
\item \texttt{echo WHAT\_TO\_IGNORE >> .gitignore}
638664
\begin{itemize}
639-
\item Aggiunge una linea con scritto \texttt{WHAT\_TO\_IGNORE} in coda al file
640-
\texttt{.gitignore}
665+
\item Aggiunge una linea con scritto \texttt{WHAT\_TO\_IGNORE} in coda al file \texttt{.gitignore}
641666
\item Funziona su tutti i sistemi!
642-
\item Consente di popolare il file \texttt{.gitignore} senza dover usare editor
643-
esterni
644-
\item e.g. \texttt{echo bin/ >> .gitignore} --- aggiunge alla lista degli ignore la
645-
cartella \texttt{bin} e tutto il suo contenuto
667+
\item Consente di popolare il file \texttt{.gitignore} senza dover usare editor esterni
668+
\item e.g. \texttt{echo bin/ >> .gitignore} --- aggiunge alla lista degli ignore la cartella \texttt{bin} e tutto il suo contenuto
646669
\end{itemize}
647670
\end{itemize}
648671
\end{block}
@@ -651,13 +674,11 @@ \subsection{Gestione dei file}
651674
\item Si compili dentro bin il file HelloWorld.java che avete creato
652675
\begin{itemize}
653676
\item Spero che vi ricordiate come si compila un file con \texttt{javac}
654-
\item Se il file non compilasse, sistematelo, quindi aggiungetelo alla staging area
655-
ed eseguite un commit
677+
\item Se il file non compilasse, sistematelo, quindi aggiungetelo alla staging area ed eseguite un commit
656678
\item Già che ci siamo, eseguite e verificate che funzioni
657679
\end{itemize}
658680
\item Si osservi lo stato del repository
659-
\item Si crei un file \texttt{.gitignore} che ignori la cartella bin e tutto il suo
660-
contenuto
681+
\item Si crei un file \texttt{.gitignore} che ignori la cartella bin e tutto il suo contenuto
661682
\item Si osservi lo stato del repository
662683
\item Si aggiunga \texttt{.gitignore} alla staging area
663684
\item Si osservi lo stato del repository

0 commit comments

Comments
 (0)