I am not asking why I cant push to a repo. I am asking what is the proper way to push a new local project to an existing repo that has a ton of different code and a lot of code from the existing project has been removed. Meaning I cant pull the project because it would add all the old code back.
I have a git project.
Project A.
I made some major changes to it so I created a new project on my localhost and copied in some of the code to make changes to it. Now that I have refactored my project I want to push this project
Project B.
To be the newest commit of project A. This way I can maintain the history of the project. Instead of removing the old project.
Question
How can I push project B. to the newest commit of Project A.
What I Tried
I opened .git/config
in project B. and changed the URL to project A.'s.
Then tried to push the project to that existing repo and I got this,
error: failed to push some refs to 'https://example.com/example/web-application.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
But if I pull in that repo I will be adding all the code Im trying to remove.