I've done git reset --hard SHA to reset to my first commit. But now I want to get rid of that commit. Is there any way to to that? Or maybe there is some command to remove all commits from the branch?
Asked
Active
Viewed 31 times
0
dansh
- 9
- 2
-
3Never encountered a situation like this. I don't think it's possible to do. I would delete the .git and start a fresh one, if you don't have nothing important in it. – riquefr Dec 18 '21 at 21:02
-
1what about `rm -rf *` in the git-bash? – Timothy Truckle Dec 18 '21 at 21:13
-
https://stackoverflow.com/search?q=%5Bgit%5D+delete+all+commits – phd Dec 18 '21 at 21:33
-
If you really wanted to get rid of _all_ commits in the repo, you would just throw away the repo. – matt Dec 18 '21 at 22:28
-
Note that a repository *is*, to a first approximation anyway, a collection of commits. As such, a repository with no commits has no function. There are some special cases, such as the bootstrap case (create empty repository for purpose of making first commit), of course, but in general if you want to remove all commits, you just remove the repository. – torek Dec 19 '21 at 03:33
-
If you want to remove all the commits from a given branch, but not from all branches in your repo -- this is another interpretation that might be what you mean -- then you can do that by simply deleting that branch. – joanis Dec 19 '21 at 14:19