Reputation: 5125
My question might seem a bit strange since what I want can usually be accomplished by simply deleting the repository and creating a new one. Here's the reason why I still need to keep the repository: The history of my repository is actually the most valuable part of the repository. I generate an entire repository with all the data. The repository is hosted on github and I want to update the repository there to look exactly like the local repository (identical history).
The only way I have found to do this so far has been to delete and recreate the repository on github before pushing to it. Otherwise all of the old commits would still be there, effectively altering the historical information of the repository. Of course it is fairly easy to recrate a repository on github but along with the repository all watchers, wiki info etc. are lost and I'd like to prevent that.
I've posted here instead of github since I think that this question is rather related to Git than to the hosting service.
Any thoughts?
Upvotes: 8
Views: 6409
Reputation: 13624
Step 1: Delete all remote branches:
git fetch
git branch -r
For each line of output (they should look like origin/master
, origin/branch1
, ...) add it to a git push
line like this:
git push origin :master :branch1 ...
Step 2: Push your local branches
git push origin master branch1 ...
Upvotes: 2
Reputation: 74222
A forced push such as git push origin +master
should help. All remote changes will be lost.
Upvotes: 5