Skip to content
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

[Feature]: SingleBranch: true in Git Clone Limits Development Environments #2241

Open
movchan74 opened this issue Jan 29, 2025 · 4 comments
Open
Labels

Comments

@movchan74
Copy link

Problem

The current implementation of git.PlainClone(...) in manager.go#L33 sets SingleBranch: true, which limits the cloned repository to a single branch. This behavior is suitable for service deployments but is counterproductive for development environments, where access to multiple branches is often required.

Observed Issues:

  • Developers cannot see or switch to other branches (git branch -r only lists the initially cloned branch).
  • Running git fetch origin does not retrieve other branches due to the restricted fetch configuration.
  • The only way to get other branches is to manually modify Git settings or re-clone the repository.

Solution

For development environments, SingleBranch: false should be used to ensure all branches are fetched. The solution is to conditionally adjust the CloneOptions based on the use case.

Workaround

Until this is fixed, users can manually reconfigure Git after cloning:

  1. Reset the fetch configuration:

    git config --unset remote.origin.fetch
    git config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
    git fetch origin --prune
  2. Verify remote branches:

    git branch -r
  3. Checkout additional branches manually:

    git checkout -b main origin/main

This allows developers to retrieve and switch between all remote branches without re-cloning the repository.

Would you like to help us implement this feature by sending a PR?

No

@r4victor
Copy link
Collaborator

@movchan74, thanks for the issue! We should certainly clone all branches for dev environments.

Do you think we should keep SingleBranch: true for services and tasks? The optimization makes sense but I'm inclined to switch to SingleBranch: false for all configurations since users may be surprised if a non-current branch works in a dev environment but not in a task.

@movchan74
Copy link
Author

@r4victor
For services and tasks, SingleBranch: true makes sense since they only need to deploy a specific branch, optimizing clone time and storage. However, it's important to have access to all branches for development environments.

In my opinion, the best approach to balancing performance and usability is to keep SingleBranch: true for services and tasks while setting SingleBranch: false for development environments.

@r4victor
Copy link
Collaborator

Ok, I think we'll make what you suggest the new default behavior, and if someone really needs SingleBranch: false for tasks/services, we may later introduce a setting to configure this.

@peterschmidt85
Copy link
Contributor

peterschmidt85 commented Jan 30, 2025

@r4victor Could it be a config property? I may imagine some users may want it to be a single branch only (e.g. to ensure git clone is fast).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants