Switching git branches

Hey all – suppose I had the following task in a playbook:

`

  • name: “Clone aire_core repo”
    git:
    repo: “git@bitbucket.org:joe/my_repo.git”
    dest: “/home/me/my_repo”

depth: 1
version: “{{ git_branch }}”
key_file: “~/.ssh/id_rsa”
update: true

`

I set git_branch to master, clone and everything is fine. However, should I choose to point my branch to foo at some point in the future, I get a complaint that git doesn’t have the foo branch.

I expected I could perhaps work around it without having to delve into code by adding a refspec attribute and seeing if it would fetch the relevant branch, to no avail.
`
refspec: “+refs/heads/{{ git_branch }}:refs/remotes/origin/{{ git_branch }}”

`

So is this desired behaviour, or is there something I’m missing? Am I really supposed to be tearing down my repo if I’m expected to be changing branches regularly?