> For the complete documentation index, see [llms.txt](https://hemantajax-2.gitbook.io/git-step-by-step/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hemantajax-2.gitbook.io/git-step-by-step/rebase.md).

# Rebase

Make linear history

EX- c1->c2->c3->c4->c5

Branch was created when master was on c2, if want to have brnach history ( b1, b2 ) starting from c5 do rebasing

```
// for doing rebase you want to switch to branch
my-branch> git rebase master|commit-hash

// after rebase
git checkout master
git merge my-branch ( will do fast forward merge)
git branch -d my-branch
(now you have completely linear history c1->c2->c3->c4->c5->b1-new->b2-new)
```

## Rebase Conflict merge

```
my-branch> git rebase master|commit-hash
(assume conflit)

// have 2 option now, after conflict current branch status will change to conflict state
git rebase --abort ( go bach to prior rebase state )
// or resolve conflict(git mergetool) than
git rebase --continue
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://hemantajax-2.gitbook.io/git-step-by-step/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.
