essential_commands.md 1.63 KB
Newer Older
Laurent Heirendt's avatar
Laurent Heirendt committed
1
2
## The 5 essential commands

Laurent Heirendt's avatar
Laurent Heirendt committed
3
4
<br>
**Yes**, you only need 5 commands!
Laurent Heirendt's avatar
Laurent Heirendt committed
5

Laurent Heirendt's avatar
Laurent Heirendt committed
6
7
<br>
`pull, status, add, commit, push`
Sylvain Arreckx's avatar
Sylvain Arreckx committed
8

Laurent Heirendt's avatar
Laurent Heirendt committed
9
10
<br>
or in other words (more technically)
Sylvain Arreckx's avatar
Sylvain Arreckx committed
11
```shell
Laurent Heirendt's avatar
Laurent Heirendt committed
12
$ git pull
Sylvain Arreckx's avatar
Sylvain Arreckx committed
13
$ git status
Laurent Heirendt's avatar
Laurent Heirendt committed
14
15
$ git add myFile.txt # example
$ git commit -m "myMessage" # example
Laurent Heirendt's avatar
Laurent Heirendt committed
16
$ git push
Sylvain Arreckx's avatar
Sylvain Arreckx committed
17
18
19
```


Laurent Heirendt's avatar
Laurent Heirendt committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
## Pull the latest version of an existing repository

First, browse to the cloned directory (`git clone [...]`):
```sh
$ cd practice
```

Then, pull the latest revision:
```sh
$ git pull
# Already up to date
```

Verify its `status` with:
```sh
$ git status
```


## Creat
Sylvain Arreckx's avatar
Sylvain Arreckx committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

Créer l'espace de travail

```shell
$ cd
$ mkdir workspace
$ cd workspace
```

Puis le dossier du nouveau projet

```shell
$ mkdir listes
$ cd listes
$ git init
```


## Nouveau fichier

Créer le fichier `courses.txt`

<div class="fragment">
```shell
$ git status
```

<div class="fragment">
```shell
$ git add courses.txt
$ git status
```

<div class="fragment">
```shell
$ git commit -m "Creation de la liste de courses"
$ git status
```

note:
    Pas besoin de serveur, pas besoin de connexion Internet


## Modification de fichier

Modifier le fichier `courses.txt`

<div class="fragment">
```shell
$ git status
```

<div class="fragment">
```shell
$ git diff courses.txt
```

<div class="fragment">
```shell
$ git add courses.txt
$ git status
```

<div class="fragment">
```shell
$ git commit -m "Ajout du beurre"
$ git status
```

<div class="fragment">
```shell
$ git log
```


## Que s'est-il passé ?


## Espace de travail

_working directory_

```shell
$ git status
  # Changes not staged for commit:
```


## Zone de transit

_index_ ou _staging area_

```shell
$ git status
  # Changes to be commited:
```