# How to Delete Commit History in Github

Follow the below steps to complete this task.\
**Warning: This will remove your old commit history completely, You can’t recover it again.**

* **Create Orphan Branch** – Create a new orphan branch in git repository. The newly created branch will not show in ‘git branch’ command.

  ```
  git checkout --orphan temp_branch
  ```
* **Add Files to Branch** – Now add all files to newly created branch and commit them using following commands.

  ```
  git add -A
  git commit -am "the first commit"
  ```
* **Delete master Branch** – Now you can delete the master branch from your git repository.

  ```
  git branch -D master
  ```
* **Rename Current Branch** – After deleting the master branch, let’s rename newly created branch name to master.

  ```
  git branch -m master
  ```
* **Push Changes** – You have completed the changes to your local git repository. Finally, push your changes to the remote (Github) repository forcefully.

  ```
  git push -f origin master
  ```

Reference: <http://stackoverflow.com/questions/13716658/how-to-delete-all-commit-history-in-github> Reference: <https://tecadmin.net/delete-commit-history-in-github/>


---

# 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://note.1810.tech/other/git/how-to-delete-commit-history-in-github.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.
