1

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?

matt
  • 515,959
  • 87
  • 875
  • 1,141
mykoman
  • 1,715
  • 1
  • 19
  • 33
  • 2
    You would have to push with `force` but of course that is going to screw up your collaborator. Basically everyone needs to stop work, agree on what goes into this repo, make it so, and clone afresh. – matt Jun 12 '20 at 04:09
  • https://stackoverflow.com/search?q=%5Bgit%5D+hint%3A+Updates+were+rejected+because+the+tip+of+your+current+branch+is+behind – phd Jun 12 '20 at 12:57

0 Answers0