# git merge — Git Fundamentals: Commits, Branches and Collaboration

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

> Combine branches with git merge and tell fast-forward merges from three-way merges.

## 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**).
