I have a repo for project A, I had to do another project B which has a lot of things common with Project A. I made a copy of project A files, I however forgot to delete the .git folder so after making updates to project B, I used git push origin master (thereby pushing all updates to repo of project A mistakenly). I collaborate on project A with someone else. I removed git origin from project B to avoid further mistake. My collaborator on project has however pulled the changes and made modification and updated the repo. I tried to do
git reset --hard previousCommit
I then added new modifications to make the project to it is meant to be. The challenge I now have is to push to the repo. When I try to push to the repo. I get the error:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://...'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
The repo requires that I pull first, and that returns me to the original state of the problem. How do I resolve this please?