# Delete commits fully

1. Get the logs for the last commits

```bash
git log -n 3 
# 3 means to list the latest 3 commits
```

2\. Rebase to the previous commit that you want to commit to

```bash
git rebase -i 77d55bd72c63d43cc83f9c0fea4990c33527c2a6
```

3\. Should enter a screen where you should pick the commit that you want

![](https://3885248957-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoE4wMO1dMVDOGDjh0En7%2Fuploads%2FzTmb0R2Xt2pwKK9RFXrU%2Fimage.png?alt=media\&token=e5cbcada-78a9-427c-8bc8-691fa6840ac5)

{% hint style="info" %}
This screen works like VIM so use dd to delete all commits that you don't want.

Leave only the one you want to revert back to
{% endhint %}

3\. Commit the changes

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

{% hint style="info" %}
You need to use the `-f` flag in order to be able to do this. Otherwise it will not allow you to do that
{% endhint %}

### Another option

Use the following code to reset head

```bash
git reset HEAD^
git push origin +HEAD
```


---

# 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://docs.arkannis.net/devops/github/delete-commits-fully.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.
