E
E
ebaysher2021-05-03 21:52:01
git
ebaysher, 2021-05-03 21:52:01

How to remove a commit on Github?

1. How to delete the very first test commit on github I tried
git reset --hard HEAD, but there is only one, and therefore I can’t find anywhere how to delete it
And how to do it so that it wouldn’t be on github either.
ps just started using git so sorry for possibly stupid questions

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Kuznetsov, 2021-05-04
@ebaysher

Since the first commit is the only one and you don't need it, you can simply delete the repository on GitHub and create it again. But you can not recreate:

# удалить все файлы в рабочей копии
git rm -r * 
# создать на месте первого коммита пустой коммит
git commit --allow-empty --amend --message "Initial commit" 
# отправить текущую ветку на GitHub 
git push --force

You will get a clean repository with an initial empty commit.
The empty commit itself can be used as the basis for building your own commit tree.
Or, through the --amend key, replace it with something more meaningful.
And it’s even better not to engage in nonsense, fix the code and fix the commit with the --amend key

T
toxa82, 2021-05-03
@toxa82

But nothing if it's your first. Delete the turnip and recreate it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question