> For the complete documentation index, see [llms.txt](https://docs.arkannis.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.arkannis.net/devops/github/delete-commits-fully.md).

# 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

![](/files/U2ZdhfI7YjYQz1SXu8ZV)

{% 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
```
