2

I've looked around for this, and have found a few topics that touch on similar issues, but I'm having a hard time really understanding a lot of terminology with git ... but this is what I am trying to do.

Basically, I have a huge, huge github repository that has been worked on for about 3 years. It has some-odd 600+ commits, 25 branches, etc.

I have made tons of backups, and also exported a copy of it to bitbucket to store all of that history ... but I would really like to just kind of 'dump' everything and start with a clean slate, without deleting the repository.

Is there any way to do that? To just kind of drop all of the commits and history, all of the branches, but not lose the repository in github without recreating it from scratch?

I'm a complete rookie with git. It's proven very difficult for me; I have a very hard time understanding all these posts with merge and rebase and ... well, everything that has to do with vim in general. I have a feeling that I have to grasp all of that a little bit to do what I want, but it's proven very frustrating to find something that just goes through it in a simple, and most importantly, working manner.

Ciel
  • 4,290
  • 8
  • 51
  • 110
  • Possible duplicate of [Make the current commit the only (initial) commit in a Git repository?](http://stackoverflow.com/questions/9683279/make-the-current-commit-the-only-initial-commit-in-a-git-repository) – Ryan Ginstrom Jan 21 '17 at 23:57
  • Patience you'll get used to it, just some more time;), btw you don't have to use vim for messages, use whatever editor you like by changing EDITOR variable in gitconfig. – Allen Jan 21 '17 at 23:58
  • One way I can think of is to "rm -rf .git", then "git init" – Allen Jan 22 '17 at 00:01
  • I totally understand if this is a duplicate of another topic. That's part of my problem, I cannot figure out exactly what to "search for" to find the answers, so I might just be missing an obvious answer because I don't know what this ... 'process' is called. – Ciel Jan 22 '17 at 00:04
  • That sounds like a very bad and unnecessary thing to do. Could you explain the 'why' of it? – Harald Nordgren Jan 22 '17 at 03:17

2 Answers2

0

To just kind of drop all of the commits and history, all of the branches, but not lose the repository in GitHub without recreating it from scratch?

Well... Actually recreating it from scratch is easier.

Following "GitHub: Renaming a repository", simply rename your old repo, create a new one with the same original name, and add your sources in that brand new "clean-slate" repo (which would reuse the same name).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Well, the other possibility is

  • Removing all the commit history by hard reset
  • Doing this will prune all the commit histories.
  • Then force push the update to GITHUB

Try this

 git reset --hard origin/master 

Then to push the commit

 git push origin <branchName> --force

To Check whether the logs are deleted, check with

 git log

After that delete all other branches using github GUI

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository#deleting-a-branch

Dr.House
  • 784
  • 5
  • 11