更改存储库 URL 后 Capistrano 部署失败
我通过 Git 存储库中的 capistrano 进行了简单的部署。起初,我从 GitHub 进行部署,一切正常。但后来我将存储库移至 BitBucket,现在我发现
fatal: Could not parse object '9cfb...'.
,问题就会消失
set :deploy_via, :remote_cache
一旦我更改为
set :deploy_via, :copy
,但这并不能解决问题,它只是绕过了它。有什么方法可以告诉 capistrano 删除旧的缓存吗?
I have a simple deployment via capistrano from a Git repository. At first I was deploying form GitHub, everything worked just fine. But then I moved my repository to BitBucket and now I'm getting
fatal: Could not parse object '9cfb...'.
The problem goes away once I change
set :deploy_via, :remote_cache
to
set :deploy_via, :copy
but that doesn't fix the problem, it only bypasses it. Is there any way I can tell capistrano to just drop the old cache?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
Capistrano 2.X
使用新地址删除并重新克隆存储库:
修改
config/deploy.rb
以使用新存储库:再次部署:
Capistrano 3.X
$deploy_to/repo
目录config/deploy.rb
(与2.X相同)cap部署
Capistrano 2.X
Delete and re-clone the repo using the new address:
Modify your
config/deploy.rb
to use the new repo:Deploy again:
Capistrano 3.X
$deploy_to/repo
directoryconfig/deploy.rb
(same as 2.X)cap deploy
我得说我不确定,因为我无法测试这一点,但这应该可行:
因为它会擦除服务器上的每个版本(缓存)。
显然,您还需要删除
shared/cached-copy
,因为根据下面的评论,上面的 Capistrano 调用似乎没有清除它。I gotta say I’m not sure, since I haven’t been able to test this but this should work:
Since it wipes every release (cache) from the server.
Apparently you will also need to remove
shared/cached-copy
, because this doesn’t seem to be cleaned by the Capistrano call above according to the comment below.Capistrano 2 及更低版本 通过
SSH 连接到您的服务器并更新部署文件夹的
./shared/cached-copy/.git/config
中的存储库,或者仅删除./shared/cached-copy
Capistrano 3 及更高版本
通过 SSH 连接到您的服务器并更新部署文件夹的
./repo/config
中的存储库。检查在存储库更改后修复 Capistrano 3 部署
Capistrano 2 and below
SSH to your server and update the repo in
./shared/cached-copy/.git/config
of the deployment folder, or just remove the./shared/cached-copy
Capistrano 3 and above
SSH to your server and update the repo in
./repo/config
of the deployment folder.Check Fixing Capistrano 3 deployments after a repository change
我通过
deploy.rb
中的以下内容解决了这个问题:它使部署速度变慢了一些,因此一旦您确信所有部署目标都已赶上,就值得将其删除。
I solved this with the following in
deploy.rb
:It makes deploys a little slower, so it's worth removing once you're comfortable that all your deploy targets have caught up.
您需要更改 /shared/cached-copy 文件夹中的 git origin
尝试cap production deploy
You need to change git origin in your /shared/cached-copy folder
try cap production deploy
最简单的方法是将存储库 URL 更改为网络服务器上的共享/缓存复制目录中的 .git/config 中的新 URL。然后就可以像往常一样进行正常部署了。
The most simple way is just changing the repo url to the new one in .git/config in the shared/cached-copy directory on the webserver. Then you can do a normal deploy as usual.
取决于您的版本 Capistrano 3 与它的老祖先不同:
在此处阅读我的原始答案以及如何解决类似问题 使用 git 更改存储库时出现 Capistrano 错误
Depends on your version Capistrano 3 is different from it's older ancestors:
Read my original answer here and how to fix similar issues Capistrano error when change repository using git
如果您需要执行大量存储库,您可能需要为其添加一个任务。
对于 capistrano 3,您可以在deploy.rb 中添加此任务
,然后为每个阶段运行一次:
If you need to do a lot of repo's you might want to add a task for it.
For capistrano 3 you add this task in your deploy.rb
And then run it once for every stage:
这是这个答案所讨论的 Capistrano 3 版本。在每台服务器上执行答案建议的操作可能会很乏味。
因此,将其放入
deploy.rb
中,然后运行 cap;部署:fix_repo_origin
Here's the Capistrano 3 version of what this answer talks about. It might be tedious to do what the answer suggests on each server.
So drop this in
deploy.rb
and then runcap <environment> deploy:fix_repo_origin
对于 Capistrano 3.0+
更改 config/deploy.rb 中的存储库 URL
更改上的 your_project/repo/config 文件中的存储库 URL服务器。
For Capistrano 3.0+
Change the repository URL in your config/deploy.rb
Change the repository URL in the your_project/repo/config file on the server.