-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Git module fails to change the current branch if there's no corresponding remote-tracking branch #82007
Comments
Files identified in the description: If these files are incorrect, please update the |
@toadjaune Can you clarify what you're trying to do? The issue summary mentions using |
Hi @mattclay, Sorry about that, the reproducer is correct, but the description was typoed. I've corrected it. Does this make the issue clear, or do you want me to add some extra clarifications ? |
The module performs a fetch before checking out the remote branch, but since it was cloned as a single-branch repo, it won't fetch other refs implicitly (see config with You could make this work with the module by setting - name: Reconfigure fetch for the git remote
command: git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
args:
chdir: /tmp/test_clone_repo |
That sounds like a nice workaround (better than always leaving It still feels like the module should handle it gracefully and not require any manual operation, though. |
I just encountered similar behaviour, should I raise another issue? Or just comment in here to see if they actually overlap? Code:
Which will give this error:
|
I also have the same issue. I am trying to checkout a specific tag from a local branch. This local branch has a remote, but it is not up-to-date and only the local branch should be checked for tags. However, because the remote does not have the latest tags, the checked out version is not changed and I end up with the wrong state. |
Summary
When cloning a git repo while specifying
single_branch: true
, a subsequent attempt to change the branch fails.My understanding of the issue is that when attempting to change the branch of an already existing repo, ansible implicitly assumes that the corresponding remote-tracking branch already exists, which may very well not be true in various situations.
Issue Type
Bug Report
Component Name
git
Ansible Version
Configuration
OS / Environment
Fedora 38 Workstation
ansible installed via pip in a virtualenv
Steps to Reproduce
Expected Results
No error, and the repo would now be checked-out on the
provisioning
branch.Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: