I made a mistake with my git repositories(edited files from the "main" one), and I had to use "git push -f" to force my "main" repository to accept my local revision. I went back to my remote main repository an开发者_Python百科d did a git status.
I see that the changes to be committed are old and do not reflect my actual local repository status (the one that pushed -f). So, if I do a git commit on the main, it works fine, but the two repositories differ.
The situation is not resolved since a new standard git push shows an error:
! [rejected] master -> master (non-fast-forward)
How can this be resolved so that my main repos has the same content as my local copy ?
You should normally not do a git push
to a non-bare repository, i.e. a repository which has a working copy attached. The reason is that git push does not update the working directory (it can't reliably do this), and thus either the HEAD gets out of sync with its branch, or out of sync with its working copy.
If you want to push to some repository, let this be a bare repository without working copy. Otherwise, use fetch
and pull
to get the changes to your repository (used at this repository itself).
精彩评论