Reputation: 477
I have a project and started work on a new version. The project by now is radically different from the previous version to the point where it shares very little of the old functionality and none of it'a API.
I'd like to transform the changes which occurred since the most recent release into a new repository. I'd like to leave the old repository behind in the state before I started refactoring.
I could simply make an initial commit in a new repository, then force revert the old repository. But I suspect this would be frowned upon strongly amidst the community.
I suspect also there is a way to do it regarding HEAD. All of my changes have been made to origin master, as it is a small library.
Upvotes: 1
Views: 636
Reputation: 66827
A git repository can point to different remote repositories.
You most likely only have origin
defined, you can list them by:
git remote show
On github, you can create a clean repository, e.g. your-user/new-remote-repo.git
. (Chose NOT to: "Initialize this repository with a README".)
Then on your local repository, you can add the new remote:
git remote add new-remote-repo [email protected]:your-user/new-repo.git
git push -u new-remote-repo master
In order to reset your current repository in time, you just checkout the relevant commit and force push it.
git checkout master
git reset --hard your-hash
git push --force origin master
I'd advise against rewriting an already published master, though. As others might already depend on your master
branch and they might get conflicted state leading to confusion.
I rather create a last-relase tag in your old repository pointing to the last working state and declare it as final release in the Readme.md
.
Upvotes: 1