通过 Ansible Playbook 克隆 Git 的特定分支

49

我正在使用Ansible部署我的应用程序。我正在使用以下命令从GitHub克隆应用程序:

- name: Deploy site files from Github repository
  sudo: yes
  git: repo=git@github.com:xyz/abc.git dest=/home/{{deploy_user}}/{{app_name}} key_file=/home/ubuntu/.ssh/id_rsa accept_hostkey=yes force=yes

我想从代码库中克隆一个特定的分支。我阅读了ansible的文档,但找不到克隆特定分支的选项。它有一个克隆版本的选项,但没有分支。

2个回答

70

来自文档

版本

检出存储库的版本。这可以是完整的40个字符的SHA-1哈希值、字面字符串HEAD、分支名称或标签名称。

(强调是我的)


注意:文档现在位于https://docs.ansible.com/ansible/latest/collections/ansible/builtin/git_module.html#parameter-version。 - kghbln

42

使用version,以下是来自文档的示例:

- git:
    repo: git://foosball.example.org/path/to/repo.git
    dest: /srv/checkout
    version: dev

注意:文档现在位于 https://docs.ansible.com/ansible/latest/collections/ansible/builtin/git_module.html#parameter-version。 - kghbln

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接