简体   繁体   English

多个Git存储库不同步

[英]Multiple Git Repositories out of sync

I have an older remote repository (repo1) that I committed some time ago but has never been pulled into another newer repository (repo2). 我有一个较早的时候提交的较旧的远程存储库(repo1),但从未将其拉入另一个较新的存储库(repo2)。 I do most of my work on repo2. 我在repo2上做了大部分工作。 When I try to push from repo2 to repo1, it asks me to do a pull from repo1. 当我尝试从repo2推送到repo1时,它要求我从repo1进行拉取。 I know there would be many conflicts since it is too old. 我知道会有太多冲突,因为它太旧了。 I don't want to pull from repo1 so I don't have to resolve the conflicts Does anyone know how to push newer version to repo1? 我不想退出repo1,所以不必解决冲突。有人知道如何将新版本推送到repo1吗? Should I just delete the repo1 and start from scratch from repo2? 我应该只删除repo1并从repo2重新开始吗? Thanks 谢谢

In case these are your own repos and you don't care about the contents of repo1, just force push to that repo. 如果这些是您自己的存储库,并且您不关心repo1的内容,只需强行推送到该存储库即可。

cd repo2
# assuming repo1 defined as remote in repo2
git push -f repo1 HEAD:master

I personally would create a branch with old stuff on repo1 before pushing new version. 我个人会在推送新版本之前在repo1上创建一个包含旧内容的分支。

cd repo1
git branch old-stuff
cd repo2
git push -f repo1 HEAD:master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM