# PipeCraft: Git Version Control for Data Teams Cheat Sheet

Core command lines for tracking data code revisions, managing development branches, and resolving code integration conflicts.

---

## 🌿 1. Branching & Synchronization

### `git checkout -b feature/model-update`
* **What it does:** Creates a new code branch named `feature/model-update` and switches your active working directory to it.

### `git fetch origin`
* **What it does:** Downloads history logs and updates references from the remote server (`origin`) without modifying any local files.

### `git rebase origin/main`
* **What it does:** Moves your local feature branch commits to sit on top of the remote main branch's latest commits.
* **Why it's used:** Maintains a clean, linear git project history.

---

## 🧹 2. Reverting & Cleaning

### `git reset --soft HEAD~1`
* **What it does:** Undoes the last commit on your active branch, but keeps your modified files staged in your working directory.
* **Why it's used:** Quickly fix typos or adjust files before re-committing code.

### `git stash` & `git stash pop`
* **What it does:**
  - `git stash`: Saves your uncommitted local changes to a temporary stack and rolls back your working directory to clean state.
  - `git stash pop`: Restores those temporarily saved changes back to your working directory.
* **Why it's used:** Safely pull server updates without committing incomplete code first.

---

## ⚔️ 3. Conflict Resolution

When multiple developers edit the same code line, Git injects conflict markers:
```text
<<<<<<< HEAD
SELECT customer_id, SUM(amount) FROM sales
=======
SELECT customer_id, SUM(amount) AS total_revenue FROM sales
>>>>>>> feature/model-update
```
* **How to fix:**
  1. Edit the file to pick the correct version (`total_revenue`).
  2. Remove all conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`).
  3. Run `git add <file>` and `git commit` to complete the merge.