I have a repository in GitHub and a local repository. I want to completely overwrite GitHub repository with local repository, overwrite everything - commit history, files, everything. These 2 repositories are not related - they are different from each other.
I need it because I made a mistake - I merged 2 unrelated repositories, in the result I have in one repo mix of both, but I have another local folder with no such mistake.
CodePudding user response:
Delete the GitHub repository and make a new one. It can have the same name if you like. Make sure it is totally empty (do NOT make a ReadMe or anything like that).
Set that new GitHub repo as the remote of your local repo (GitHub tells you how to do that when you create the repo).
On your local machine, push every branch (you might, depending on your settings, be able to simplify with
git push --all
, but if not you will just have to push each branch individually).
CodePudding user response:
If it doesn't need to be the exact same Github repository, you might be able to follow the steps detailed here: https://docs.github.com/en/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github I am not entirely sure, but you might be able to also push to an existing repository as well with this method.