I've set up a remote non-bare "main" repo and cloned it to my computer.
(我已经建立了一个远程的非裸露的“主”仓库,并将其克隆到我的计算机上。)
I made some local changes, updated my local repository, and pushed the changes back to my remote repo. (我进行了一些本地更改,更新了本地存储库,然后将更改推回到远程仓库中。)
Things were fine up to that point. (到那时为止一切都很好。)
Now, I had to change something in the remote repo.
(现在,我不得不更改远程仓库中的某些内容。)
Then I changed something in my local repo. (然后,我更改了本地存储区中的某些内容。)
I realized that the change to the remote repo was not needed. (我意识到不需要更改远程仓库。)
So I tried to git push
from my local repo to my remote repo, but I got an error like: (所以我尝试将本地存储库中的git push
送到远程存储库中,但是出现类似以下错误:)
To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again.
(为了防止丢失历史记录,拒绝了非快进更新,请在合并之前合并远程更改。)
See the 'Note about fast-forwards' section of git push --help
for details. (有关详细信息,请参见git push --help
的“关于快进的说明”部分。)
I thought that probably a
(我以为可能)
git push --force
would force my local copy to push changes to the remote one and make it the same.
(会强制我的本地副本将更改推送到远程副本,并使其相同。)
It does force the update , but when I go back to the remote repo and make a commit, I notice that the files contain outdated changes (ones that the main remote repo previously had). (它确实强制执行更新 ,但是当我返回到远程存储库并进行提交时,我注意到文件包含了过时的更改(主要远程存储库以前具有的更改)。)
As I mentioned in the comments to one of the answers :
(正如我在对答案之一的评论中提到的 :)
[I] tried forcing, but when going back to master server to save the changes, i get outdated staging.
([我]尝试强制执行,但是当回到主服务器以保存更改时,我得到了过时的暂存。)
Thus, when i commit the repositories are not the same. (因此,当我提交存储库时,它们是不一样的。)
And when i try to use git push again, i get the same error. (当我再次尝试使用git push时,出现相同的错误。)
How can I fix this issue?
(如何解决此问题?)
ask by Spyros translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…