# git rebase?!

<https://hackernoon.com/git-merge-vs-rebase-whats-the-diff-76413c117333>

### The one-line summary: don’t rebase a branch unless you are the only one who uses it. Or you enjoy chaos.

In summary, when looking to incorporate changes from one Git branch into another:

* Use merge in cases where you want a set of commits to be clearly grouped together in history
* Use rebase when you want to keep a linear commit history
* DON'T use rebase on a public /shared branch

## Merge

```
git checkout master
git merge feature
```

By merging **feature** into **master**, master obtains a new commit -- a "merge commit".

![](/files/-LgDoSs-K1LgqFg2nJKI)

![](/files/-LgDoSs1OPLdGFIW4mTG)

## Rebase

re-base

Before we continue working on our feature branch, we decide we want to bring in the latest changes from master to keep things fresh.

Rather that merging master's new commits into feature, we opt to *rebase* our feature branch onto master.

```
git checkout feature
git rebase master
```

At a high level, rebasing can be understood as "moving the base of a branch onto a different position". Think of it like a redo--"I meant to start here."

![](/files/-LgDoSs3nVoFCaBrePL7)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lin-4.gitbook.io/my-git-cheat-sheet/git-rebase.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
