# Astuces Git

### Usage GIT:

([https://docs.gitlab.com/ee/gitlab-basics/start-using-git.html](https://docs.gitlab.com/ee/gitlab-basics/start-using-git.html))

```bash
git config --global user.name "your_username"
git config --global user.email "your_email_address@example.com"
git clone http://ansible.myvlab.io/cidou/tests-ansible
(avec synchro)
git download
(sans synchro)
```

### config initiale

```bash
git config --global cedric.quillevere "Cedric Quillevere"
git config --global user.email "cedric@vblog.io"
git config --global --list
```

### Configuration globale de Git

```bash
git config --global user.name "Cédric Quillévéré"
git config --global user.email "cedric@vblog.io"
git config --global pull.rebase false  # merge (the default strategy)
git config --global pull.rebase true   # rebase
git config --global pull.ff only       # fast-forward only
```

### Pousser un dossier existant dans un repo deja créé sous Gitlab

```bash
exemple de session pour initialiser un rep git et pousser le code/script sur celui-ci :
git init
git checkout -b main
git add */docker-compose.*
git add */.env
git add */*.yml
git add */*.yaml
git add */*.json
git commit -m "initial commit /home"
git remote add origin git@gitea.naoned.net:cedric/xxxxxxxx.git
git push -u origin main --force
```

### Initialisation via gitea

```bash
touch README.md
git init
git checkout -b main
git add README.md
git commit -m "first commit"
git remote add origin https://gitea.naoned.net/cedric/test.git
git push -u origin main
```

### Divers git

```bash
git fetch (se synchro avec repo distant, sans répliquer)
git pull (synchroniser un repo distant en local)
git checkout -b <branch> (changer ou créer une branch particulière dans un repo git)
git push --set-upstream origin <branch> (branch a publier online)
git checkout <branch_actuelle> (se dépacer dans la branch "branch_actuelle")
git merge <branch> (merger la branch "branch" dans la branch actuelle)
```
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9