Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
git_tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orestis.malaspin
git_tutorial
Commits
8de71779
Verified
Commit
8de71779
authored
3 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
updated slides with gitignore in base tutorial
parent
e5c2d675
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
git_tutorial.md
+65
-16
65 additions, 16 deletions
git_tutorial.md
git_tutorial_gitignore.md
+1
-1
1 addition, 1 deletion
git_tutorial_gitignore.md
with
66 additions
and
17 deletions
git_tutorial.md
+
65
−
16
View file @
8de71779
% Introduction à Git
% Introduction à Git
% Orestis Malaspinas
% Orestis Malaspinas
% commit e
e7a89cab009aba5b291125eb0b28a4bd7034fc9
% commit e
5c2d675e68c4df94a9d3b0df48f8feb5ec9c1ab
# Des références
# Des références
...
@@ -55,7 +55,7 @@ Typiquement un projet git possède un serveur "officiel" géré par l'administra
...
@@ -55,7 +55,7 @@ Typiquement un projet git possède un serveur "officiel" géré par l'administra
# Principe de fonctionnement de Git (3/3)
# Principe de fonctionnement de Git (3/3)

{width="80%"}

{width="80%"}
# Exemple de fonctionnement
# Exemple de fonctionnement
...
@@ -358,6 +358,15 @@ Automatic merge failed; fix conflicts and then commit the result.
...
@@ -358,6 +358,15 @@ Automatic merge failed; fix conflicts and then commit the result.
### Il ne reste qu'à corriger le conflit et refaire un `git commit`, `git push`
### Il ne reste qu'à corriger le conflit et refaire un `git commit`, `git push`
# Un `git push` par erreur
*
Un
`git push`
est très difficile à "effacer".
*
Cela revient à
*réécrire*
l'historique de votre projet.
*
Cela est
*dangereux*
, surtout quand on travail à plusieurs.
*
Le plus simple est de revenir à une version antérieure et faire un nouveau
commit.
*
Il existe des techniques
*violentes*
qu'on verra pas ici.
# Retirer un fichier du contrôle de version (1/3)
# Retirer un fichier du contrôle de version (1/3)
## Commande: `git rm`
## Commande: `git rm`
...
@@ -366,9 +375,9 @@ Automatic merge failed; fix conflicts and then commit the result.
...
@@ -366,9 +375,9 @@ Automatic merge failed; fix conflicts and then commit the result.
-
**Attention : le fichier ne disparaît pas de l'historique.**
-
**Attention : le fichier ne disparaît pas de l'historique.**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{.bash}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{.bash}
[
malaspor
@perka tutorial]$ git rm premierfichier.c
[
orestis
@perka tutorial]$ git rm premierfichier.c
rm 'premierfichier.c'
rm 'premierfichier.c'
[
malaspor
@perka tutorial]$ git status
[
orestis
@perka tutorial]$ git status
On branch master
On branch master
Your branch is up to date with 'origin/master'.
Your branch is up to date with 'origin/master'.
...
@@ -376,7 +385,7 @@ Changes to be committed:
...
@@ -376,7 +385,7 @@ Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
(use "git reset HEAD <file>..." to unstage)
deleted: premierfichier.c
deleted: premierfichier.c
[
malaspor
@perka tutorial]$ git commit -am "efface donc ce fichier"
[
orestis
@perka tutorial]$ git commit -am "efface donc ce fichier"
[master 8f76d90] efface donc ce fichier
[master 8f76d90] efface donc ce fichier
1 file changed, 1 deletion(-)
1 file changed, 1 deletion(-)
delete mode 100644 premierfichier.c
delete mode 100644 premierfichier.c
...
@@ -387,12 +396,12 @@ Changes to be committed:
...
@@ -387,12 +396,12 @@ Changes to be committed:
## Commande: `git rm` (1/2)
## Commande: `git rm` (1/2)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{.bash}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{.bash}
[
malaspor
@perka tutorial]$ ls -ltr
[
orestis
@perka tutorial]$ ls -ltr
total 0
total 0
[
malaspor
@perka tutorial]$ git reset bbb151324289dc2f85468f5721ec1021692dd216
[
orestis
@perka tutorial]$ git reset bbb151324289dc2f85468f5721ec1021692dd216
Unstaged changes after reset:
Unstaged changes after reset:
D premierfichier.c
D premierfichier.c
[
malaspor
@perka tutorial]$ git status
[
orestis
@perka tutorial]$ git status
On branch master
On branch master
Your branch is up to date with 'origin/master'.
Your branch is up to date with 'origin/master'.
...
@@ -412,26 +421,66 @@ no changes added to commit (use "git add" and/or "git commit -a")
...
@@ -412,26 +421,66 @@ no changes added to commit (use "git add" and/or "git commit -a")
On peut retrouver le fichier dans l'historique.
On peut retrouver le fichier dans l'historique.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{.bash}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{.bash}
[
malaspor
@perka tutorial]$ ls -ltr
[
orestis
@perka tutorial]$ ls -ltr
total 0
total 0
[
malaspor
@perka tutorial]$ git checkout premierfichier.c
[
orestis
@perka tutorial]$ git checkout premierfichier.c
[
malaspor
@perka tutorial]$ ls -ltr
[
orestis
@perka tutorial]$ ls -ltr
total 4
total 4
-rw-r--r-- 1
malaspor malaspor
17 5 mar 11:13 premierfichier.c
-rw-r--r-- 1
orestis orestis
17 5 mar 11:13 premierfichier.c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~
# Commandes et concept un peu plus avancés
# Commandes et concept un peu plus avancés
Il existe une
**grande quantité**
de fonctionnalités non discutées ici:
Il existe une
**grande quantité**
de fonctionnalités non discutées ici:
1.
`
.
git
ignore
`
1.
`git
branch
`
2.
`git
branch
`
2.
`git
merge
`
3.
`git
merge
`
3.
`git
tag
`
4.
`git
tag
`
4.
`git
rebase
`
**ET SURTOUT:**
**ET SURTOUT:**
5.
`git trois-lignes-de-commandes-incompréhensibles-que-seul stackoverflow-peut-vous-permettre-d'écrire`
5.
`git trois-lignes-de-commandes-incompréhensibles-que-seul stackoverflow-peut-vous-permettre-d'écrire`
# Le fichier `.gitignore`
## L'état des fichiers
Git voit les fichiers dans trois états possibles:
1.
*tracked*
, un fichier qui a été
`add`
(
`staged`
) ou
`commit`
(dans la terminologie git).
2.
*untracked*
, un fichier qui n'a pas été
`add`
ou
`commit`
.
3.
*ignored*
, un fichier qui est explicitement ignoré par git.
## Quels fichiers ignorer
On ignore typiquement:
*
Les fichiers binaires: exécutables, images, ...
*
Les produits de compilation:
`*.o`
,
`*.pyc`
, ...
*
Les produits d'exécutions: logs, ...
*
Les fichiers de configuration d'un IDE: .vscode, ...
*
Les fichiers système.
## Comment ignorer des fichiers?
*
Créer un fichier texte nommé
`.gitignore`
.
*
L'ajouter au répo git et le "commit".
*
Y ajouter les règles à suivre pour ignorer les fichiers.
Exemple: [^1]
```
bash
biden
# ignore le fichier biden
*
.o
# ignore tous les fichier `.o`
!
trump.o
# mais PAS trump.o
sanders
# ignore le répertoire sanders
**
/sanders
# ignore tous les répertoires sanders
```
[
^1
]:
Pour
une liste plus exhaustive voir le site
<https://bit.ly/2HTZJyQ>
par exemple.
## Bibliographie
Ces quelques slides sont inspirés du site
<https://bit.ly/2HTZJyQ>
.
This diff is collapsed.
Click to expand it.
git_tutorial_gitignore.md
+
1
−
1
View file @
8de71779
% Introduction à Git partie 2
% Introduction à Git partie 2
% Orestis Malaspinas
% Orestis Malaspinas
% commit e
e7a89cab009aba5b291125eb0b28a4bd7034fc9
% commit e
5c2d675e68c4df94a9d3b0df48f8feb5ec9c1ab
# Le fichier `.gitignore`
# Le fichier `.gitignore`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment