开发者

Git : Why Do I See Previously Committed Changes?

开发者 https://www.devze.com 2023-02-21 20:42 出处:网络
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 ma

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消