0

What I'd like to do in my Git repository (specifically GitLab) is to delete all previous commits, preferably also branches that are not main, issues etc, while keeping the current version of files.

I'd like to achieve an effect like I had created a totally new repository, adding the current files as initial ones.

Is it possible to achieve something like this using standard git commands or GitLab / GitLab API?

Thanks for the all answers in advance!

Dr. Ske
  • 69
  • 6
  • Does this answer your question? [Make the current commit the only (initial) commit in a Git repository?](https://stackoverflow.com/questions/9683279/make-the-current-commit-the-only-initial-commit-in-a-git-repository) – Michael Delgado Nov 17 '22 at 15:11
  • I've seen this one. It kind of solves my problem but since I am using GitLab, which automatically marks main branch as "Protected" (what diasloves a force push on this branch), I have to take off the protection, run the git commands, and apply protection on the new branch. It all makes this solution non-elegant imho and I was looking for something gitlab-internal (but not a trace of solution in docs unfortunatelly) – Dr. Ske Nov 19 '22 at 15:33
  • 1
    There’s not going to be an elegant way to destroy the git history. That is the solution. Part of protecting the branch is preventing stuff like this. – Michael Delgado Nov 19 '22 at 15:50

0 Answers0