31-05-2020
This commit is contained in:
@@ -117,17 +117,40 @@ $ git commit –m 'version initiale du projet'
|
||||
|
||||
#### [Cloner un dépôt existant:](https://git-scm.com/book/fr/v1/Les-bases-de-Git-D%C3%A9marrer-un-d%C3%A9p%C3%B4t-Git#Cloner-un-d%C3%A9p%C3%B4t-existant)
|
||||
|
||||
```bash
|
||||
$ git clone git://github.com/depot/projet.git
|
||||
```
|
||||
Bash.git est un repo --bare sur le NAS.
|
||||
|
||||
Crée un répertoire <u>grit</u> contenant les données du dépôt ainsi qu'un répertoire .git
|
||||
Créer un répertoire contenant les données du dépôt (working tree) ainsi qu'un répertoire .git
|
||||
|
||||
```bash
|
||||
$ git clone git://github.com/depot/projet.git mondossier
|
||||
$ git clone ssh://bruno@clicclac.synology.me:42666/volume1/Repositories/bash.git
|
||||
|
||||
$ cd bash
|
||||
drwxr-xr-x 12 bruno staff 384 May 8 07:46 .git
|
||||
-rw-r--r-- 1 bruno staff 10 May 8 07:46 .gitignore
|
||||
-rwxr-xr-x 1 bruno staff 3317 May 8 07:46 apache_tools.sh
|
||||
-rwxr-xr-x 1 bruno staff 5158 May 8 07:46 backup-conf.sh
|
||||
```
|
||||
|
||||
Crée un clone du depot dans le dossier mondossier
|
||||
Créer un répertoire Repo contenant les données du dépôt (working tree) ainsi qu'un répertoire .git
|
||||
|
||||
```bash
|
||||
$ git clone ssh://bruno@clicclac.synology.me:42666/volume1/Repositories/bash.git Repo
|
||||
|
||||
$ cd Repo
|
||||
drwxr-xr-x 12 bruno staff 384 May 8 07:46 .git
|
||||
-rw-r--r-- 1 bruno staff 10 May 8 07:46 .gitignore
|
||||
-rwxr-xr-x 1 bruno staff 3317 May 8 07:46 apache_tools.sh
|
||||
-rwxr-xr-x 1 bruno staff 5158 May 8 07:46 backup-conf.sh
|
||||
```
|
||||
|
||||
Créer uniquement le répertoire .git (pas de working tree)
|
||||
|
||||
```bash
|
||||
$ git clone --mirror ssh://bruno@clicclac.synology.me:42666/volume1/Repositories/bash.git
|
||||
|
||||
$ ls -la
|
||||
drwxr-xr-x 10 bruno staff 320 May 8 08:01 bash.git
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -396,12 +419,22 @@ $ git remote show KYMSU
|
||||
master pousse vers master (à jour)
|
||||
```
|
||||
|
||||
##### Ajouter un dépot distant:
|
||||
#### Ajouter un dépot distant:
|
||||
|
||||
```bash
|
||||
$ git remote add origin git@gitea.maboiteverte.fr:bruno/yuzu-child_mbv.git
|
||||
```
|
||||
|
||||
```bash
|
||||
GIT_SSL_NO_VERIFY=true git remote add origin ssh://bruno@192.168.1.7:42666/volume1/Repositories/shell_scripts.git
|
||||
```
|
||||
|
||||
#### Corriger l'URL d'un dépôt distant:
|
||||
|
||||
```bash
|
||||
$ git remote set-url origin git@gitea.maboiteverte.fr:bruno/yuzu-child_mbv.git
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Etiquettes:
|
||||
@@ -587,6 +620,10 @@ Avec la commande rebase, vous prenez toutes les modifications qui ont été vali
|
||||
|
||||
#### => [Session de travail avec git](git-session.md) <=
|
||||
|
||||
#### => [Synchroniser 2 dépôts (--bare)](sync-repo.md) <=
|
||||
|
||||
#### => [git sur Plesk](../../Plesk/git.md) <=
|
||||
|
||||
|
||||
|
||||
http://www.ntu.edu.sg/home/ehchua/programming/howto/Git_HowTo.html
|
||||
146
docs/Divers/git/sync-repo.md
Normal file
146
docs/Divers/git/sync-repo.md
Normal file
@@ -0,0 +1,146 @@
|
||||
# Synchroniser 2 dépôts (--bare):
|
||||
|
||||
|
||||
|
||||
ssh://bruno@clicclac.synology.me:42666/volume1/Repositories/wp_yuzu-child.git
|
||||
|
||||
bruno@maboiteverte.fr:~/git/wp_yuzu-child.git
|
||||
|
||||
```bash
|
||||
$ git clone --mirror ssh://bruno@clicclac.synology.me:42666/volume1/Repositories/wp_yuzu-child.git
|
||||
|
||||
$ cd wp_yuzu-child.git
|
||||
total 16
|
||||
-rw-r--r-- 1 bruno staff 23 May 8 09:13 HEAD
|
||||
-rw-r--r-- 1 bruno staff 253 May 8 09:13 config
|
||||
-rw-r--r-- 1 bruno staff 73 May 8 09:13 description
|
||||
drwxr-xr-x 14 bruno staff 448 May 8 09:13 hooks
|
||||
drwxr-xr-x 3 bruno staff 96 May 8 09:13 info
|
||||
drwxr-xr-x 4 bruno staff 128 May 8 09:13 objects
|
||||
-rw-r--r-- 1 bruno staff 105 May 8 09:13 packed-refs
|
||||
drwxr-xr-x 4 bruno staff 128 May 8 09:13 refs
|
||||
|
||||
$ nano config
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = true
|
||||
ignorecase = true
|
||||
precomposeunicode = true
|
||||
[remote "origin"]
|
||||
url = ssh://bruno@clicclac.synology.me:42666/volume1/Repositories/wp_yuzu-child.git
|
||||
fetch = +refs/*:refs/*
|
||||
mirror = true
|
||||
|
||||
```
|
||||
|
||||
On ajoute le second dépôt distant:
|
||||
|
||||
```bash
|
||||
$ git remote add --mirror=fetch secondary ssh://bruno@maboiteverte.fr:~/git/wp_yuzu-child.git
|
||||
|
||||
$ nano config
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = true
|
||||
ignorecase = true
|
||||
precomposeunicode = true
|
||||
[remote "origin"]
|
||||
url = ssh://bruno@clicclac.synology.me:42666/volume1/Repositories/wp_yuzu-child.git
|
||||
fetch = +refs/*:refs/*
|
||||
mirror = true
|
||||
[remote "secondary"]
|
||||
url = bruno@maboiteverte.fr:~/git/wp_yuzu-child.git
|
||||
fetch = +refs/*:refs/*
|
||||
```
|
||||
|
||||
On récupère les commits et refs du 1er dépôt (origin):
|
||||
|
||||
```bash
|
||||
$ git fetch origin
|
||||
|
||||
$ l
|
||||
total 20
|
||||
-rw-r--r-- 1 bruno staff 142 May 8 09:25 FETCH_HEAD <-
|
||||
-rw-r--r-- 1 bruno staff 23 May 8 09:13 HEAD
|
||||
-rw-r--r-- 1 bruno staff 357 May 8 09:18 config
|
||||
-rw-r--r-- 1 bruno staff 73 May 8 09:13 description
|
||||
drwxr-xr-x 14 bruno staff 448 May 8 09:13 hooks
|
||||
drwxr-xr-x 3 bruno staff 96 May 8 09:13 info
|
||||
drwxr-xr-x 4 bruno staff 128 May 8 09:13 objects
|
||||
-rw-r--r-- 1 bruno staff 105 May 8 09:13 packed-refs
|
||||
drwxr-xr-x 4 bruno staff 128 May 8 09:13 refs
|
||||
|
||||
$ nano FETCH_HEAD
|
||||
e3bd4d1ce81a2a0c6f87f713ec7a84ae4327c87a not-for-merge branch 'master' of ssh://clicclac.synology.me:42666/volume1/Repositories/wp_yuzu-child
|
||||
```
|
||||
|
||||
On met à jour le second dépôt (avec local refs)
|
||||
|
||||
```bash
|
||||
$ git push secondary --all
|
||||
Enumerating objects: 42, done.
|
||||
Counting objects: 100% (42/42), done.
|
||||
Delta compression using up to 8 threads
|
||||
Compressing objects: 100% (24/24), done.
|
||||
Writing objects: 100% (42/42), 529.85 KiB | 88.31 MiB/s, done.
|
||||
Total 42 (delta 16), reused 42 (delta 16), pack-reused 0
|
||||
remote: % Total % Received % Xferd Average Speed Time Time Time Current
|
||||
remote: Dload Upload Total Spent Left Speed
|
||||
remote: 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
|
||||
To maboiteverte.fr:~/git/wp_yuzu-child.git
|
||||
* [new branch] master -> master
|
||||
```
|
||||
|
||||
On vérifie sur le second dépôt:
|
||||
|
||||
```bash
|
||||
bruno@localhost:~/git/wp_yuzu-child.git$ l
|
||||
total 40
|
||||
drwxr-xr-x 7 bruno psacln 4096 May 8 09:39 .
|
||||
drwxr-xr-x 5 bruno psacln 4096 May 8 08:47 ..
|
||||
drwxr-xr-x 2 bruno psacln 4096 May 8 08:47 branches
|
||||
-rw-r--r-- 1 bruno psacln 66 May 8 08:47 config
|
||||
-rw-r--r-- 1 bruno psacln 73 May 8 08:47 description
|
||||
-rw-r--r-- 1 bruno psacln 23 May 8 09:39 HEAD <-
|
||||
drwxr-xr-x 2 bruno psacln 4096 May 8 08:47 hooks
|
||||
drwxr-xr-x 2 bruno psacln 4096 May 8 08:47 info
|
||||
drwxr-xr-x 43 bruno psacln 4096 May 8 09:39 objects <-
|
||||
drwxr-xr-x 4 bruno psacln 4096 May 8 08:47 refs
|
||||
```
|
||||
|
||||
Les 2 dépôts ont maintenant les mêmes fichiers et historiques.
|
||||
|
||||
|
||||
|
||||
A partir de la, pour maintenir les 2 dépôts synchronisés:
|
||||
|
||||
- un nouveau commit est crée sur le 1er dépôt:
|
||||
|
||||
```bash
|
||||
$ git fetch origin
|
||||
$ git push secondary --all
|
||||
```
|
||||
|
||||
- un nouveau commit est crée sur le 2nd dépôt:
|
||||
|
||||
```bash
|
||||
$ git fetch secondary
|
||||
$ git push origin
|
||||
```
|
||||
|
||||
- les 2 dépôts sont modifiés:
|
||||
|
||||
```bash
|
||||
# mkdir ../workdir
|
||||
# git fetch origin
|
||||
# git --work-tree=../workdir/ checkout branch_name file_name1
|
||||
# git fetch secondary
|
||||
# git --work-tree=../workdir/ checkout branch_name file_name2
|
||||
# git push secondary
|
||||
# git push origin
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user