## git merge vs git rebase
When there are changes on the `main` branch that you want to incorporate into your branch, you can either _merge_ the changes in or _rebase_ your branch from a different point
**merge** takes the changes from one branch and merges them into another branch in one _merge commit_.
```zsh
git merge origin/main your-branch
```
**rebase** adjusts the point at which a branch actually branched off (i.e. moves the branch to a new starting point from the base branch).
```zsh
git rebase origin/main your-branch
```
_Generally,_ you’ll use `rebase` when there are changes in an upstream branch (like `main`) that you want to include in your branch. You’ll use `merge` when there are changes in a branch that you want to put into `main`.
Rebase onto the upstream `main` branch frequently.
- It's easier to fix any merge issues sooner rather than later. While you may not need to rebase after every commit, it should still be a regular practice to make it easier on yourself when it comes time to merge your code in.
#### More info
[Use Git like a senior engineer](https://levelup.gitconnected.com/use-git-like-a-senior-engineer-ef6d741c898e)
[Avoid Git Merge Conflicts During a Big Rebase](https://felixrieseberg.com/better-rebasing/)
___
**Tags**: