# git merge — Git

Source: https://www.geekswithgeeks.com/en/git/git-merge-basics

> Combine one branch's history into another — fast-forward vs three-way.

## Merging a branch in

Switch to the branch you want to merge **into**, then merge the other one in.

```bash
git switch main
git merge feature/login
```

Output:

```
Updating a1b2c3d..9f8e7d6
Fast-forward
 login.js | 12 ++++++++++++
```

## Fast-forward vs 3-way

If `main` hasn't moved since the branch split off, Git just slides the pointer forward (**fast-forward**). If both sides have new commits, Git creates a new **merge commit** joining both histories (**3-way merge**).
