Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| 56-tools:git [2019/02/10 11:25] – [Serveur GIT] Roge | 56-tools:git [2023/12/13 01:08] (Version actuelle) – [Créer un repository bare] Roge | ||
|---|---|---|---|
| Ligne 65: | Ligne 65: | ||
| Avantage : l' | Avantage : l' | ||
| + | |||
| + | |||
| + | ===== Intialiser le remote à partir du local ===== | ||
| + | |||
| + | <code bash> | ||
| + | # Crée l' | ||
| + | git init < | ||
| + | |||
| + | # dans le dossier local racine | ||
| + | git remote add origin <URL> | ||
| + | # mise à jour de l' | ||
| + | git push origin master | ||
| + | # Tous les autres utilisateurs peuvent alors se synchroniser avec l' | ||
| + | git pull | ||
| + | </ | ||
| ===== Configuration ===== | ===== Configuration ===== | ||
| Ligne 142: | Ligne 157: | ||
| - | ===== Git checkout | + | ===== SOS ===== |
| - | on peut récupérer | + | Afficher |
| - | '' | + | '' |
| + | |||
| + | Suppression définitive d' | ||
| + | |||
| + | Récupérer uniquement quelques fichiers : | ||
| + | |||
| + | '' | ||
| + | |||
| + | Normalement Git ne supprime pas de commit, donc si on est perdu : | ||
| + | |||
| + | '' | ||
| + | |||
| + | On peut alors revenir sur un commit particulier avec : | ||
| + | |||
| + | '' | ||
| + | |||
| + | If you want to get list of changed files: | ||
| + | |||
| + | '' | ||
| + | |||
| + | If you want to get list of all files in a commit, you can use | ||
| + | |||
| + | '' | ||
| + | ===== Pull - fetch ===== | ||
| + | |||
| + | La commande **git fetch** va récupérer toutes les données des commits effectués sur la branche courante qui n' | ||
| + | |||
| + | La commande **git pull** est en fait la commande qui regroupe les commandes **git fetch** suivie de **git merge**. Cette commande télécharge les données des commits qui n'ont pas encore été récupérées dans votre branche locale puis fusionne ensuite ces données. | ||
| + | |||
| + | |||
| + | ===== Exemple ===== | ||
| + | |||
| + | < | ||
| + | # | ||
| + | # Configuration de Git | ||
| + | # | ||
| + | hal:/ | ||
| + | [core] | ||
| + | repositoryformatversion = 0 filemode = true bare = false | ||
| + | logallrefupdates = true | ||
| + | [branch " | ||
| + | remote = / | ||
| + | merge = refs/ | ||
| + | [remote " | ||
| + | url = / | ||
| + | fetch = refs/ | ||
| + | / | ||
| + | push = master fetch = master | ||
| + | # | ||
| + | # Création du dossier de travail avec initialisation Git | ||
| + | # | ||
| + | hal:/data $ git init Test-Git | ||
| + | Initialized empty Git repository in / | ||
| + | # | ||
| + | # Création du dossier de référence avec initialisation Git --bare | ||
| + | # | ||
| + | hal:/data $ cd /bkp/GITs/ | ||
| + | hal:/ | ||
| + | Initialized empty Git repository in / | ||
| + | hal:/ | ||
| + | $ cd Test-Git/ | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | total 8 drwxr-xr-x 7 roge roge 4096 Nov 9 09:08 .git -rw-r--r-- 1 roge roge 3 Nov 9 09:10 test.txt | ||
| + | # | ||
| + | # Status | ||
| + | # | ||
| + | hal:/ | ||
| + | On branch master Initial commit | ||
| + | Untracked files: (use "git add < file> | ||
| + | test.txt nothing added to commit but untracked files present (use "git add" to track) | ||
| + | # | ||
| + | Ajout dans Git | ||
| + | # | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | On branch master Initial commit Changes to be committed: | ||
| + | (use "git rm --cached < file> | ||
| + | # | ||
| + | # Commit | ||
| + | # | ||
| + | hal:/ | ||
| + | [master (root-commit) 95defef] v1 1 file changed, 1 insertion( ) create mode 100644 test.txt | ||
| + | # Vérification | ||
| + | hal:/ | ||
| + | 2016-11-09 12:38 (HEAD -> master) dd4b48d roge v1.1 | ||
| + | 2016-11-09 09:10 95defef roge v1 | ||
| + | # | ||
| + | Mise à jour du repository de reference | ||
| + | # | ||
| + | hal:/ | ||
| + | master Counting objects: 3, done. Writing objects: 100% (3/3), 197 bytes | 0 bytes/s, done. | ||
| + | Total 3 (delta 0), reused 0 (delta 0) To / | ||
| + | * [new branch] master -> master | ||
| + | # Vérification | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | $ git log | ||
| + | 2016-11-09 12:38 (HEAD -> master) dd4b48d roge v1.1 | ||
| + | 2016-11-09 09:10 95defef roge v1 | ||
| + | # | ||
| + | # Modification du fichier et commit | ||
| + | # | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | On branch master | ||
| + | Changes not staged for commit: (use "git add < file> | ||
| + | to update what will be committed) (use "git checkout -- < file> | ||
| + | to discard changes in working directory) | ||
| + | modified: test.txt no changes added to commit (use "git add" and/or "git commit -a") | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | [master dd4b48d] v1.1 1 | ||
| + | file changed, 1 insertion( ), 1 deletion(-) | ||
| + | hal:/ | ||
| + | Counting objects: 3, done. | ||
| + | Writing objects: 100% (3/3), 228 bytes | 0 bytes/s, done. | ||
| + | Total 3 (delta 0), reused 0 (delta 0) To / | ||
| + | 95defef..dd4b48d master -> master | ||
| + | hal:/ | ||
| + | 2016-11-09 12:38 (HEAD -> master) dd4b48d roge v1.1 | ||
| + | 2016-11-09 09:10 95defef roge v1 | ||
| + | # | ||
| + | # 3ième modification du fichier | ||
| + | # | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | [master f9239f9] V1.2 1 | ||
| + | file changed, 1 insertion( ), 1 deletion(-) | ||
| + | hal:/ | ||
| + | Counting objects: 3, done. | ||
| + | Writing objects: 100% (3/3), 230 bytes | 0 bytes/s, done. | ||
| + | Total 3 (delta 0), reused 0 (delta 0) To / | ||
| + | master -> master Branch master set up to track remote branch master from / | ||
| + | # | ||
| + | # Création d'une branche | ||
| + | # | ||
| + | hal:/ | ||
| + | master Switched to a new branch ' | ||
| + | # | ||
| + | # Création de changements | ||
| + | # | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | [new-feature f37b89e] | ||
| + | start new feature 1 file changed, 1 insertion( ), 1 deletion(-) | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | [new-feature 06f6e84] End new feature 1 file changed, 1 insertion( ), 1 deletion(-) | ||
| + | hal:/ | ||
| + | 2016-11-09 13:15 (HEAD -> new-feature) 06f6e84 roge End new feature | ||
| + | 2016-11-09 13:14 f37b89e roge start new feature | ||
| + | 2016-11-09 13:02 (master) 58f89b5 roge V1.2.2 | ||
| + | 2016-11-09 13:02 71f0700 roge V1.2.1 | ||
| + | 2016-11-09 12:56 (test-feature) f9239f9 roge V1.2 | ||
| + | 2016-11-09 12:38 dd4b48d roge v1.1 | ||
| + | 2016-11-09 09:10 95defef roge v1 | ||
| + | # | ||
| + | # Merge: test-feature --> master | ||
| + | # | ||
| + | hal:/ | ||
| + | hal:/ | ||
| + | Updating 58f89b5..06f6e84 Fast-forward test.txt | 2 - 1 file changed, 1 insertion( ), 1 deletion(-) | ||
| + | # Suppression de la branche | ||
| + | hal:/ | ||
| + | Deleted branch new-feature (was 06f6e84). | ||
| + | hal:/ | ||
| + | 2016-11-09 13:15 (HEAD -> master) 06f6e84 roge End new feature | ||
| + | 2016-11-09 13:14 f37b89e roge start new feature | ||
| + | 2016-11-09 13:02 58f89b5 roge V1.2.2 | ||
| + | 2016-11-09 13:02 71f0700 roge V1.2.1 | ||
| + | 2016-11-09 12:56 (test-feature) f9239f9 roge V1.2 | ||
| + | 2016-11-09 12:38 dd4b48d roge v1.1 | ||
| + | 2016-11-09 09:10 95defef roge v1 | ||
| + | # | ||
| + | # Mise à jour du repository de reference | ||
| + | # | ||
| + | hal:/ | ||
| + | Counting objects: 12, done. | ||
| + | Delta compression using up to 8 threads. | ||
| + | Compressing objects: 100% (4/4), done. | ||
| + | Writing objects: 100% (12/12), 852 bytes | 0 bytes/s, done. | ||
| + | Total 12 (delta 0), reused 0 (delta 0) To / | ||
| + | f9239f9..06f6e84 master -> master | ||
| + | # Vérification | ||
| + | 2016-11-09 13:15 (HEAD -> master) 06f6e84 roge End new feature | ||
| + | 2016-11-09 13:14 f37b89e roge start new feature | ||
| + | 2016-11-09 13:02 58f89b5 roge V1.2.2 | ||
| + | 2016-11-09 13:02 71f0700 roge V1.2.1 | ||
| + | 2016-11-09 12:56 f9239f9 roge V1.2 | ||
| + | 2016-11-09 12:38 dd4b48d roge v1.1 | ||
| + | 2016-11-09 09:10 95defef roge v1 | ||
| + | </ | ||
| - | ou récupérer uniquement quelques fichiers : | ||
| - | '' | ||
| ===== Git tag ===== | ===== Git tag ===== | ||