talas-group/04_INFRA_DEPLOIEMENT/Notes_Operations/git_cheatsheet.txt
senke 66471934af Initial commit: Talas Group project management & documentation
Knowledge base of ~80+ markdown files across 14 domains (00-13),
Logseq graph, hardware design files (KiCAD), infrastructure configs,
and talas-wiki static site.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 20:10:41 +02:00

140 lines
2.7 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Perfect — if you're just creating a **sandbox branch** to test or combine the content of `master`, `A`, and `B` **without committing anything**, that makes things even easier. Here's how you do it 👇
---
## ✅ Objective
Create a **temporary branch `C`** with:
- All from `master`
- All from branch `A`
- All from branch `B`
**Without committing anything** — just to play with the merged result.
---
## 🛠️ Steps (safe, no commits to `A`, `B`, or `master`)
```bash
# 1. Start from master
git checkout master
# 2. Create a sandbox branch (you can name it whatever)
git checkout -b sandbox-merge
# 3. Merge branch A without committing (staging only)
git merge --no-commit --no-ff A
# 4. Merge branch B without committing (again, staging only)
git merge --no-commit --no-ff B
```
At this point:
- Youre on branch `sandbox-merge`
- You have a working directory with combined changes from `master + A + B`
- **Nothing has been committed**
---
### 💥 Want to discard everything when you're done?
```bash
git checkout master
git branch -D sandbox-merge # deletes the temp branch
```
---
### 🔄 Want to try again later?
Just repeat the steps.
---
### ✅ Bonus: Prevent accidental commits
You can even configure your sandbox branch like this:
```bash
git checkout -b sandbox-merge
git config branch.sandbox-merge.mergeoptions "--no-commit --no-ff"
```
Parfaitement clair 👇
Tu veux **sauvegarder temporairement tes fichiers modifiés localement** sans les committer, **changer de branche**, puis **les retrouver plus tard en revenant**.
---
## ✅ Solution : utiliser `git stash`
Cest exactement fait pour ça.
---
### 🛠️ Étapes simples
#### 1. Sauvegarde tes modifications sans les perdre :
```bash
git stash push -m "sauvegarde temporaire coraza"
```
> Optionnel mais conseillé : ajoute un message pour savoir ce que contient la stash
---
#### 2. Change de branche sans problème :
```bash
git checkout feature/IT-14817_coraza_waf
```
🎉 Ça passe sans erreur maintenant.
---
#### 3. Plus tard, quand tu veux retrouver tes modifs :
Retourne sur ta branche de départ :
```bash
git checkout ma-branche-initiale
```
Puis récupère ce que tu as stashed :
```bash
git stash pop
```
---
### 🧠 Bonus : plusieurs stashes ?
Tu peux voir ce que tu as sauvegardé :
```bash
git stash list
```
Et appliquer une stash spécifique :
```bash
git stash apply stash@{1}
```
Ou la supprimer manuellement si plus utile :
```bash
git stash drop stash@{1}
```
---
### ❗ À savoir
- `git stash pop` = applique et supprime
- `git stash apply` = applique sans supprimer (utile pour tester)
- Tu peux aussi stasher **seulement certains fichiers** si besoin
---