r/GithubCopilot • • 24d ago

Help/Doubt ❓ How to disable worktrees?

Lately noticing CP keeps creating a worktree in my local repo instead of using the current branch. I have to prompt it every time to not do that. Can this be disabled in cp settings?

5 Upvotes

16 comments sorted by

3

u/Lonsarg 24d ago

Yes this is VERY annoying.

Enough for us ti stop promoting Copilot App companywide and just promote CLI instead.

Why this stupid default of creating a new worktree by default, this should be advanced non-default setting.

2

u/SpearHammer 23d ago

It's not stupid. It's so you can have multiple agents working concurrently instead of sitting idle waiting for 1 to finish it's job

-3

u/Lonsarg 23d ago edited 23d ago

And have them generate merge conflicts? Hell no, if you need more agents to work at the same moment on the same codebase, then you should:

  1. Divide your codebase into separate repos
  2. OR Give BOTH jobs to the same agent and let him spawn subagents (Copilot Fusion does this automatically). If you do both at the same time you will probably also deploy at the same time or testing will be a bottleneck (or use feature flags is separate deployment is a requirnament)

Also no was in hell will i allow agent to commit in git, i have him in sandbox with no git push, i open separately the same folder and do review and then commit. This is VERY annoying to do if separate worktree.

Also I have team members starting to use Desktop Copilot App and then asking me "i can not find where this code from this session is". Very very bad default experience, at least make it as mandatory selection with no default.

2

u/pantinor 21d ago

Agreed - it never commits the code for me - I do that myself.

1

u/hellycopterinjuneer 22d ago

Instead of downvoting, can someone recommend a better way to deal with this?

1

u/Alternative-Class834 22d ago

Be clever about scoping the work pr session. Cleverly scoped work reduces likelyhood of overlap and resulting conflicts. Feature flags as you mentioned, makes it OK to be be completely done with feature, before creating new session. 

2

u/pantinor 21d ago

This is why I find it simpler to work in a single branch and review the changes files after each prompt completes - it is just easier for me. Our group is ramping up with AI and struggling with whether to trust the code generated roughly - or inspect every line carefully to avoid making it a black box - but the trend seems to be going with agentic where you just roughly understand what the code does rather than understanding every line of code.

3

u/XzAeRosho VS Code User 💻 24d ago

Almost all AI agents like doing that for some reason, not just in Copilot. I've added a rule in my repo to prevent it of doing that, and so far so good.

1

u/Lonsarg 24d ago edited 23d ago

Yes but Copilot Desktop app has a "new sesstion dropdown" where you select new or existing worktree BEFORE AI agent is online.

So you cannot automate or change this setting via agent instructions You are forced to chose this manually, and default is new worktree...

Edit: Apparently once you chose existing checkout per repo, then next session on same repo will default to existing checkout. Still annoying but better.

1

u/pantinor 24d ago

Solution is in settings, under sessions, under app instructions, add when working locally use the existing checkout. Fo not create the worktree

4

u/Astrophizz 24d ago

If you're in the agents window you can switch it to branch mode and it will just make changes on the current branch, or another of your choosing.

1

u/Alternative-Class834 22d ago

Funny, I am switching to the app from CLI, to make it easier for me to use sessions and worktrees 😅 

2

u/pantinor 21d ago

Yes they are useful just not for my workflow

1

u/AutoModerator 24d ago

Hello /u/pantinor. Looks like you have posted a query. Once your query is resolved, please reply the solution comment with "!solved" to help everyone else know the solution and mark the post as solved.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

0

u/[deleted] 23d ago

[deleted] — view deleted comment

3

u/pantinor 23d ago

I'm not using parallel agents just chat session. Need to review all the edits after each prompt finishes before prompting again.

0

u/[deleted] 23d ago

[deleted] — view deleted comment

3

u/pantinor 23d ago

It's not my boss, it's me. I need to explain the code during code reviews and am accountable for what it generates.