You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an important section to absorb, because if you understand what Git is and the fundamentals of how it works, then using Git effectively will probably be much easier for you.
5
10
As you learn Git, try to clear your mind of the things you may know about other VCSs, such as CVS, Subversion or Perforce -- doing so will help you avoid subtle confusion when using the tool.
6
11
Even though Git's user interface is fairly similar to these other VCSs, Git stores and thinks about information in a very different way, and understanding these differences will help you avoid becoming confused while using it.(((Subversion)))(((Perforce)))
12
+
////
13
+
14
+
15
+
Quindi, cos'è Git in poche parole?
16
+
Questa è una sezione importante da comprendere, perché se capisci che cos'è Git e gli elementi fondamentali di come funziona, allora sarà probabilmente molto più facile per te usare efficacemente Git.
17
+
Mentre impari Git, cerca di liberare la tua mente dalle cose che eventualmente già conosci di altri VCS come CVS, Subversion e Perforce -- ciò ti aiuterà a evitare di far confusione utilizzando lo strumento.
18
+
Anche se l'interfaccia utente di Git è abbastanza simile a quella degli altri VCS, Git immagazzina e tratta le informazioni in modo molto diverso, e comprendere queste differenze aiuta ad evitare di sentirsi confusi mentre lo si usa.
7
19
20
+
////
8
21
==== Snapshots, Not Differences
22
+
////
9
23
24
+
==== Istantanee, non Differenze
25
+
26
+
////
10
27
The major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data.
11
28
Conceptually, most other systems store information as a list of file-based changes.
12
29
These other systems (CVS, Subversion, Perforce, Bazaar, and so on) think of the information they store as a set of files and the changes made to each file over time (this is commonly described as _delta-based_ version control).
30
+
////
31
+
32
+
La principale differenza tra Git e gli altri VCS (inclusi Subversion e simili), è come Git considera i suoi dati.
33
+
Concettualmente la maggior parte degli altri sistemi salvano l'informazione come una lista di modifiche ai file.
34
+
Questi altri sistemi (CVS, Subversion, Perforce, Bazaar e così via), considerano le informazioni che memorizzano come un insieme di file, con le relative modifiche fatte nel tempo (questo viene normalmente descritto come controllo di versione _su base delta_).
13
35
36
+
////
14
37
.Storing data as changes to a base version of each file.
15
38
image::images/deltas.png[Storing data as changes to a base version of each file.]
39
+
////
16
40
41
+
.Memorizzazione dei dati come cambiamenti di ogni file da una versione di base.
42
+
image::images/deltas.png[Memorizzazione dei dati come cambiamenti di ogni file da una versione di base]
43
+
44
+
////
17
45
Git doesn't think of or store its data this way.
18
46
Instead, Git thinks of its data more like a series of snapshots of a miniature filesystem.
19
47
With Git, every time you commit, or save the state of your project, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.
20
48
To be efficient, if files have not changed, Git doesn't store the file again, just a link to the previous identical file it has already stored.
21
49
Git thinks about its data more like a *stream of snapshots*.
50
+
////
51
+
52
+
Git non considera i dati né li registra in questo modo.
53
+
Git considera i propri dati più come una sequenza di istantanee (_snapshot_) di un mini filesystem.
54
+
Con Git, ogni volta che registri (_commit_), o salvi lo stato del tuo progetto, fondamentalmente lui fa un'immagine di tutti i file in quel momento, salvando un riferimento allo _snapshot_.
55
+
Per essere efficiente, se alcuni file non sono cambiati, Git non li risalva, ma crea semplicemente un collegamento al file precedente già salvato.
56
+
Git considera i propri dati più come un *flusso di istantanee*.
22
57
58
+
////
23
59
.Storing data as snapshots of the project over time.
24
60
image::images/snapshots.png[Git stores data as snapshots of the project over time.]
61
+
////
25
62
63
+
.Memorizzazione dei dati come snapshot del progetto nel tempo.
64
+
image::images/snapshots.png[Memorizzazione dei dati come snapshot del progetto nel tempo]
65
+
66
+
////
26
67
This is an important distinction between Git and nearly all other VCSs.
27
68
It makes Git reconsider almost every aspect of version control that most other systems copied from the previous generation.
28
69
This makes Git more like a mini filesystem with some incredibly powerful tools built on top of it, rather than simply a VCS.
29
70
We'll explore some of the benefits you gain by thinking of your data this way when we cover Git branching in <<ch03-git-branching#ch03-git-branching>>.
71
+
////
72
+
73
+
Questa è una distinzione importante tra Git e pressocché tutti gli altri VCS.
74
+
Git riconsidera quasi tutti gli aspetti del controllo di versione che la maggior parte degli altri sistemi ha copiato dalle generazioni precedenti.
75
+
Questo rende Git più simile a un mini filesystem con a disposizione strumenti incredibilmente potenti che un semplice VCS.
76
+
Esploreremo alcuni benefici che ottieni pensando in questo modo ai tuoi dati e vedremo le ramificazioni in Git nel <<ch03-git-branching#ch03-git-branching>>.
30
77
78
+
////
31
79
==== Nearly Every Operation Is Local
80
+
////
32
81
82
+
==== Quasi Tutte le Operazioni Sono Locali
83
+
84
+
////
33
85
Most operations in Git need only local files and resources to operate -- generally no information is needed from another computer on your network.
34
86
If you're used to a CVCS where most operations have that network latency overhead, this aspect of Git will make you think that the gods of speed have blessed Git with unworldly powers.
35
87
Because you have the entire history of the project right there on your local disk, most operations seem almost instantaneous.
88
+
////
89
+
90
+
La maggior parte delle operazioni in Git, necessitano solo di file e risorse locali per operare -- generalmente non occorrono informazioni da altri computer della rete.
91
+
Se sei abituato ad un CVCS in cui la maggior parte delle operazioni sono soggette alle latenze di rete, questo aspetto di Git ti farà pensare che gli Dei della velocità abbiano benedetto Git con poteri soprannaturali.
92
+
Poiché hai l'intera storia del progetto sul tuo disco locale, molte operazioni sembrano quasi istantanee.
36
93
94
+
////
37
95
For example, to browse the history of the project, Git doesn't need to go out to the server to get the history and display it for you -- it simply reads it directly from your local database.
38
96
This means you see the project history almost instantly.
39
97
If you want to see the changes introduced between the current version of a file and the file a month ago, Git can look up the file a month ago and do a local difference calculation, instead of having to either ask a remote server to do it or pull an older version of the file from the remote server to do it locally.
98
+
////
40
99
100
+
Per esempio, per navigare la storia di un progetto, Git non ha bisogno di connettersi al server per scaricarla e per poi mostrarla -- la legge direttamente dal tuo database locale.
101
+
Questo significa che puoi vedere la storia del progetto quasi istantaneamente.
102
+
Se vuoi vedere le modifiche introdotte tra la versione corrente e la versione di un mese fa di un file, Git può accedere al file com'era un mese fa e calcolare le differenze localmente, invece di dover chiedere a un server remoto di farlo o di scaricare dal server remoto una versione precedente del file, per poi farlo in locale.
103
+
104
+
////
41
105
This also means that there is very little you can't do if you're offline or off VPN.
42
106
If you get on an airplane or a train and want to do a little work, you can commit happily (to your _local_ copy, remember?) until you get to a network connection to upload.
43
107
If you go home and can't get your VPN client working properly, you can still work.
44
108
In many other systems, doing so is either impossible or painful.
45
109
In Perforce, for example, you can't do much when you aren't connected to the server; in Subversion and CVS, you can edit files, but you can't commit changes to your database (because your database is offline).
46
110
This may not seem like a huge deal, but you may be surprised what a big difference it can make.
111
+
////
112
+
113
+
Questo significa anche che sono pochissime le cose che non puoi fare se sei offline o non sei connesso alla VPN.
114
+
Se sei in aereo o sul treno e vuoi fare un po' di lavoro, puoi eseguire _commit_ tranquillamente (alla tua copia locale, ricordi?) in attesa di essere di nuovo connesso per fare l'upload.
115
+
Se vai a casa e il tuo client VPN non funziona correttamente, puoi lavorare ugualmente.
116
+
In molti altri sistemi questo è impossibile o molto penoso.
117
+
Con Perforce, per esempio, puoi fare ben poco se non sei connesso al server; e con Subversion e CVS, puoi modificare i file, ma non puoi registrare le modifiche sul tuo database (perché il database è offline).
118
+
Tutto ciò potrebbe non sembrarti una gran cosa, ma potrebbe sorprenderti quanta differenza possa fare.
47
119
120
+
////
48
121
==== Git Has Integrity
122
+
////
49
123
124
+
==== Git Ha Integrità
125
+
126
+
////
50
127
Everything in Git is checksummed before it is stored and is then referred to by that checksum.
51
128
This means it's impossible to change the contents of any file or directory without Git knowing about it.
52
129
This functionality is built into Git at the lowest levels and is integral to its philosophy.
53
130
You can't lose information in transit or get file corruption without Git being able to detect it.
131
+
////
132
+
54
133
134
+
Qualsiasi cosa in Git è controllata, tramite checksum, prima di essere salvata ed è referenziata da un checksum.
135
+
Questo significa che è impossibile cambiare il contenuto di qualsiasi file o directory senza che Git lo sappia.
136
+
Questa è una funzionalità interna di basso livello di Git ed è intrinseca della sua filosofia.
137
+
Non può capitare che delle informazioni in transito si perdano o che un file si corrompa senza che Git non sia in grado di accorgersene.
138
+
139
+
////
55
140
The mechanism that Git uses for this checksumming is called a SHA-1 hash.(((SHA-1)))
56
141
This is a 40-character string composed of hexadecimal characters (0–9 and a–f) and calculated based on the contents of a file or directory structure in Git.
57
142
A SHA-1 hash looks something like this:
143
+
////
144
+
145
+
Il meccanismo che Git usa per fare questo checksum è un hash chiamato SHA-1.(((SHA-1)))
146
+
Si tratta di una stringa di 40-caratteri, composta da caratteri esadecimali (0–9 ed a–f) e calcolata in base al contenuto di file o della struttura della directory in Git.
147
+
Un hash SHA-1 assomiglia a qualcosa come:
148
+
58
149
59
150
[source]
60
151
----
61
152
24b9da6552252987aa493b52f8696cd6d3b00373
62
153
----
63
154
155
+
////
64
156
You will see these hash values all over the place in Git because it uses them so much.
65
157
In fact, Git stores everything in its database not by file name but by the hash value of its contents.
158
+
////
159
+
160
+
Vedrai questi hash dappertutto in Git perché li usa tantissimo.
161
+
Infatti Git salva qualsiasi cosa nel suo database, e il riferimento ad un file non è basato sul nome del file, ma sull'hash del suo contenuto.
66
162
163
+
////
67
164
==== Git Generally Only Adds Data
165
+
////
166
+
167
+
==== Git Generalmente Aggiunge Solo Dati
68
168
169
+
////
69
170
When you do actions in Git, nearly all of them only _add_ data to the Git database.
70
171
It is hard to get the system to do anything that is not undoable or to make it erase data in any way.
71
172
As with any VCS, you can lose or mess up changes you haven't committed yet, but after you commit a snapshot into Git, it is very difficult to lose, especially if you regularly push your database to another repository.
173
+
////
72
174
175
+
Quasi tutte le azioni in Git _aggiungono_ dati al database di Git.
176
+
È difficile fare qualcosa che non sia annullabile o che cancelli i dati in una qualche maniera.
177
+
Come con gli altri VCS, puoi perdere o fare confusione con le modifiche che non
178
+
hai ancora registrato (commit), ma dopo aver registrato uno snapshot in Git, è veramente difficile perderle, specialmente se regolarmente fai il push del tuo database su un altro repository.
179
+
180
+
////
73
181
This makes using Git a joy because we know we can experiment without the danger of severely screwing things up.
74
-
For a more in-depth look at how Git stores its data and how you can recover data
75
-
that seems lost, see <<ch02-git-basics-chapter#_undoing>>.
182
+
For a more in-depth look at how Git stores its data and how you can recover data that seems lost, see <<ch02-git-basics-chapter#_undoing>>.
183
+
////
184
+
185
+
Questo rende piacevole l'uso di Git perché sappiamo che possiamo sperimentare senza il pericolo di causare danni pesanti.
186
+
Per un maggior approfondimento su come Git salvi i dati e come tu possa recuperare quelli che sembrino persi, consulta il <<ch02-git-basics-chapter#_undoing>>.
76
187
188
+
////
77
189
==== The Three States
190
+
////
78
191
192
+
==== I Tre Stati
193
+
194
+
////
79
195
Pay attention now -- here is the main thing to remember about Git if you want the rest of your learning process to go smoothly.
80
196
Git has three main states that your files can reside in: _modified_, _staged_, and _committed_:
81
-
82
197
* Modified means that you have changed the file but have not committed it to your database yet.
83
198
* Staged means that you have marked a modified file in its current version to go into your next commit snapshot.
84
199
* Committed means that the data is safely stored in your local database.
200
+
////
85
201
202
+
Attenzione adesso -- qui c'è la cosa principale da ricordare di Git se vuoi affrontare al meglio il processo di apprendimento.
203
+
I file in Git possono essere in tre stati principali: _modified_ (modificati), _staged_ (in stage) e _committed_ (committati).
204
+
* Modificato significa che il file è stato modificato, ma non è ancora stato committato nel database.
205
+
* In stage significa che hai contrassegnato un file, modificato nella versione corrente, perché venga inserito nello snapshot alla prossima commit.
206
+
* Committato significa che il file è registrato al sicuro nel database locale.
207
+
208
+
////
86
209
This leads us to the three main sections of a Git project: the working tree, the staging area, and the Git directory.
210
+
////
211
+
87
212
213
+
Questo ci porta alle tre sezioni principali di un progetto Git: l'albero di lavoro, l'area di stage e la directory di Git,
214
+
215
+
////
88
216
.Working tree, staging area, and Git directory.
89
217
image::images/areas.png["Working tree, staging area, and Git directory."]
218
+
////
219
+
220
+
.Albero di lavoro, area di stage e directory di Git.
221
+
image::images/areas.png["Albero di lavoro, area di stage e directory di Git."]
90
222
223
+
////
91
224
The working tree is a single checkout of one version of the project.
92
225
These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.
93
226
@@ -96,14 +229,39 @@ Its technical name in Git parlance is the ``index'', but the phrase ``staging ar
96
229
97
230
The Git directory is where Git stores the metadata and object database for your project.
98
231
This is the most important part of Git, and it is what is copied when you _clone_ a repository from another computer.
232
+
////
233
+
234
+
L'albero di lavoro è un checkout di una versione specifica del progetto.
235
+
Questi file vengono estratti dal database compresso nella directory di Git, e salvati sul disco per essere usati o modificati.
236
+
237
+
L'area di stage è un file, contenuto generalmente nella directory di Git, con tutte le informazioni riguardanti la tua prossima commit.
238
+
Il suo nome tecnico nel gergo di Git è 'indice', ma l'espressione 'area di stage' (area di sosta, ndt) funziona altrettanto bene.
99
239
240
+
La directory di Git è dove Git salva i metadati e il database degli oggetti del tuo progetto.
241
+
Questa è la parte più importante di Git, ed è ciò che viene copiato quando si clona un repository da un altro computer.
242
+
243
+
////
100
244
The basic Git workflow goes something like this:
101
245
102
246
1. You modify files in your working tree.
103
247
2. You selectively stage just those changes you want to be part of your next commit, which adds _only_ those changes to the staging area.
104
248
3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
249
+
////
250
+
251
+
Il flusso di lavoro (_workflow_) di base in Git funziona così:
105
252
253
+
1. Modifica i file nel tuo albero di lavoro
254
+
2. Seleziona per lo stage solo quei cambiamenti che vuoi facciano parte del tuo prossimo commit, che aggiunge solo queste modifiche all'area di stage.
255
+
3. Committa, ovvero salva i file nell'area di stage in un'istantanea (_snapshot_) permanente nella tua directory di Git.
256
+
257
+
////
106
258
If a particular version of a file is in the Git directory, it's considered _committed_.
107
259
If it has been modified and was added to the staging area, it is _staged_.
108
260
And if it was changed since it was checked out but has not been staged, it is _modified_.
109
261
In <<ch02-git-basics-chapter#ch02-git-basics-chapter>>, you'll learn more about these states and how you can either take advantage of them or skip the staged part entirely.
262
+
////
263
+
264
+
Se una particolare versione di un file è nella directory git, viene considerata già committata (_committed_).
265
+
Se il file è stato modificato, ma è stato aggiunto all'area di staging, è _in stage_.
266
+
E se è stato modificato da quando è stata estratto, ma non è _in stage_, è _modificato_.
267
+
In <<ch02-git-basics-chapter#ch02-git-basics-chapter>>, imparerai di più su questi stati e come trarne vantaggio o saltare la parte di staging.
0 commit comments