简体   繁体   English

在Capistrano部署后承诺回购生产

[英]Commit to repo on production after Capistrano deploy

For obscure, painful operational reasons, production code needs to check code into the main Git repo. 由于晦涩难懂的操作原因,生产代码需要将代码检入主Git存储库中。

However, Capistrano 3, on deploy, does: 但是,Capistrano 3在部署时会:

execute :git, :clone, '--mirror', repo_url, repo_path

The --mirror option, implies --bare , which creates the directory structure without the .git meta data. --mirror选项隐含--bare ,它创建目录结构而没有.git元数据。

Is there a way to override this in Capistrano 3? 在Capistrano 3中有没有方法可以覆盖此问题?

Since you are committing code from the production (which is usually a strict no - you should create a patch from the diff , and apply it locally and then do a push), I assume you already have access to your production server. 由于您要从生产中提交代码(通常严格禁止-您应从diff创建patch ,然后在本地应用它,然后进行推送),因此我假设您已经可以访问生产服务器。

This is a soultion outside the Capistrano framework. 这是Capistrano框架之外的灵魂。 You need to do the following: 您需要执行以下操作:

  1. Make the commit on the production site 在生产现场进行提交
  2. Push it from there (from your server) to your hosting 从那里(从您的服务器)将其推送到主机
    2.1. 2.1。 ie, push it to your hosted repo location (like github/bitbucket/gitlab) 即,将其推送到您的托管存储库位置(如github / bitbucket / gitlab)
    2.2. 2.2。 Use the http(s) url here (because otherwise you might have to set up ssh keys) 在此处使用http(s) url(因为否则可能需要设置ssh密钥)
  3. Pull those changes into your local developer machine 将这些更改放入本地开发人员计算机
  4. Do a fresh deploy with capistrano from your local machine. 使用本地计算机上的capistrano进行全新部署。

However, I would recommend creating a patch and applying it as follows: 但是,我建议创建补丁并将其应用如下:

  1. Go to your production server, don't make any commits there 转到生产服务器,不要在此处进行任何提交
  2. Create a diff file of all existing files, using git diff > diff.patch.date 使用git diff > diff.patch.date创建所有现有文件的diff文件
  3. Copy this patch file to one of your local systems using scp server/path/to/diff.patch.date local/path/to/repo 使用scp server/path/to/diff.patch.date local/path/to/repo将此补丁文件复制到本地系统之一
  4. Apply the patch using git apply diff.patch.date 使用git apply diff.patch.dategit apply diff.patch.date
  5. Add and commit the changes using git add . && git commit -m "msg" 使用git add . && git commit -m "msg"添加并提交更改git add . && git commit -m "msg" git add . && git commit -m "msg"
  6. Now do a cap deploy 现在进行上限部署

EDIT 编辑

After re-reading your question, it seems that Capistrano is creating a bare repo, and hence you are unable to make the commits from there. 重新阅读您的问题后,Capistrano似乎正在创建裸仓库,因此您无法从那里进行提交。 If that is the case, 如果是这样,

  1. Just make another non bare clone of the repo using git clone original_bare_rep non_bare_repo 只需使用git clone original_bare_rep non_bare_repo制作另一个非裸露的git clone original_bare_rep non_bare_repo
  2. Add your gitlab/bitbucket url etc as a remote using git remote add upstream url/to/repo/hosting 使用git remote add upstream url/to/repo/hosting gitlab / bitbucket url等添加为git remote add upstream url/to/repo/hosting
  3. commit your changes and push them to upstream 提交更改并将其推向上游
  4. You can now do a fresh cap deploy, or push to the bare repo directly. 现在,您可以重新部署上限,或直接推送到裸仓库。

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

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