Files
git-cheatsheet-ita/docs/02-clone-e-struttura-repo.md
T

86 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- File: 02-clone-e-struttura-repo.md -->
# Clonare il repository e primi comandi
## Clonare un repository
Come `svn checkout`, ma con Git:
```bash
git clone https://git.meridiana.it/progetto/repo.git
cd repo
```
Questo crea una cartella `repo` con:
* una copia completa della storia
* un **remote** chiamato `origin` che punta al server
Puoi vedere i remote configurati:
```bash
git remote -v
```
Esempio di output:
```text
origin https://git.meridiana.it/progetto/repo.git (fetch)
origin https://git.meridiana.it/progetto/repo.git (push)
```
## Stato del repository
Per vedere cosa è cambiato rispetto allultimo commit:
```bash
git status
```
Esempio:
```text
On branch develop
Your branch is up to date with 'origin/develop'.
Changes not staged for commit:
modified: src/main.py
Untracked files:
docs/nuovo-documento.md
```
## Vedere la storia dei commit
```bash
git log
```
Versione compatta:
```bash
git log --oneline --graph --decorate --all
```
Esempio:
```text
* a1b2c3d (HEAD -> develop, origin/develop) Fix bug nel calcolo totale
* 9f8e7d6 Aggiunge endpoint /health
* 1a2b3c4 Inizializza progetto
```
## Confrontare differenze
Differenze rispetto allultimo commit:
```bash
git diff
```
Differenze per un singolo file:
```bash
git diff path/al/file.ext
```