0

I would like to put an old Git Repo I have for a website publicly on GitHub. I cannot do this because the repo contains the original site and its files as well as the current one. The current one is a complete rewrite of the old site and thus, shares no files with it. Sadly, when I was originally creating it, I branched in the repo and did my rewrite there, then merged it back into master.

I do not want the old version of the website to be public, but I do want to be able to get to it to check files and content if I need to review something. I'd like to have my repo for the new site start from where I originally branched to now, keeping my recent commit history.

I have some ideas for how this probably could be done, but nothing concrete. Here's what I'm thinking:

  1. Rename this repo to -old and run some fancy script that takes all commits from a certain starting point and adds then to a new repo.
  2. Take the original repo up to the point where it was modified and create a new -old version of it. Somehow rewrite Git history in the current repo from a commit to the new one.
  3. Create a branch of master and somehow rewrite Git history in the current repo from a commit to the new one.
  4. [DO NOT WANT TO DO THIS] Create a new repo and start over.
Kevin Ghadyani
  • 6,829
  • 6
  • 44
  • 62
  • Your answer is here: http://stackoverflow.com/questions/34519665/how-to-move-head-checkout-revert-reflog-reset/34519716#34519716. fell free to vote for tit if you like it. – CodeWizard Jan 28 '16 at 04:33
  • I do not see how that solves my issue. It only allows me to go back in time, not remove the past. – Kevin Ghadyani Jan 29 '16 at 02:40

1 Answers1

1

You're looking for git rebase, which rewrites history.

Switch to the branch you want to rewrite, run git rebase --root --interactive, then rewrite history to your heart's content.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Is there an easy way to do what I want or do I have to go through hundreds of old commits by hand and tell it to remove them? – Kevin Ghadyani Jan 28 '16 at 04:32
  • Use your favorite editor to delete all of the commits above the line you want at once. – SLaks Jan 28 '16 at 04:37
  • I got it working with Sublime Text and found that after I rebased, it only did it on one branch and re-created all commits in a new branch dated today, not the dates the commits happened. – Kevin Ghadyani Jan 29 '16 at 01:31