Skip to content

Add support for treating worktrees like regular repos #907

Closed

Description

@shana

Git now officially supports worktrees, which are git clones that are mirrored/linked to a master clone.

https://git-scm.com/docs/git-worktree

The way it works is, when you run git worktree add, git checks out whatever branch you gave it (or creates a new branch - worktrees can never be on the same branch as the main clone), and creates a .git file that contains:

gitdir: [path to the original clone]/.git/worktrees/[name of worktree directory]

A worktree is a "view" of the original clone set to a different branch. Committing on a worktree is the same as committing on the original clone, you can cherry-pick/merge as usual, the database is shared. merge states are separate, as is the reflog.

Activity

  1. elan commented on Sep 20, 2017

    @elan

    This would be awesome; the only GUI git app I know which handles this right now is Tower.app.

  2. JESii commented on Nov 13, 2017

    @JESii

    I'm sorry... what is the Ask here? Seems like this is just a description of what already happens...

  3. shana commented on Nov 13, 2017

    @shana
    Author

    @JESii This is a description of what git does, to help guide the support for it in GitHub Desktop (which doesn't handle this out of the box)

  4. elan commented on Nov 13, 2017

    @elan

    @JESii ~ I swear I tried it before and it didn't work, but you're right, I was able to open a worktree directory inside the app and it seemed to work perfectly (commit & push both worked fine). The one tweak which would be awesome is displaying the worktree as part of the sidebar, since right now worktree and parent look identical.

  5. JESii commented on Nov 16, 2017

    @JESii

    Got it, @shana; thanks!

  6. shivakumargarag commented on Jun 23, 2022

    @shivakumargarag

    @JESii This is a description of what git does, to help guide the support for it in GitHub Desktop (which doesn't handle this out of the box)

    What I understand from the discussion here is that Github Desktop does not support Worktree feature yet and it is being worked upon?

  7. ekimbernow commented on Jun 23, 2022

    @ekimbernow

    At least when I last tested it, if you add a repo or worktree directory to GitHub desktop and maybe perform some other action, not sure, it will create spurious and incorrect staging records for other worktrees in the same repository.

    I haven't had the direction from my management to actually look into the code to see what's going on but if feels like a simple bug where something is making a bad assumption or something.

    So while GitHub Desktop recognizes worktree directories just fine, there is a bad bug with how it handles repositories that use work trees.

  8. ekimbernow commented on Jun 23, 2022

    @ekimbernow

    For the ServiceNow platform documentation we use git repositories that manage multiple versions of the platform documentation on different branches, where we have at least four versions under active support and development. These repositories are very large (10s of GB of history, ~6GB of working data on any version's branch).

    Our authors have a long-standing practice of cloning each version's branch into a separate directory, but today they make a separate clone (we currently use Eclipse as the git GUI for authors and JGit does not recognize work trees at all).

    Work trees would be the ideal solution to this crazy work practice (it was put in place years ago) and we very much want to replace Eclipse with GitHub Desktop as our supported GUI solution for ServiceNow writers. Support for worktree is not a must-have--authors can continue to make separate clones as they do today and it will work just fine--but we would really like work trees to be fully supported.

  9. ekimbernow commented on Jun 23, 2022

    @ekimbernow

    Another twiddle is that following a fetch the UI reports the origin as "Never fetched" rather than having just been fetched.

  10. ekimbernow commented on Jun 23, 2022

    @ekimbernow

    I reproduced the spurious staged files issue just now:

    I have a repo with a number of work trees checked out.

    I added one of those work trees to Desktop. The work tree has two untracked files as the only pending unstaged change.

    I add that worktree directory to Desktop. It shows the two unstaged files as the list of changed files (which is correct)

    I did a fetch and then a Pull rebase.

    After the pull the repo has a number of staged files that were not changed and are not the result of a merge conflict (meaning those files were neither modified locally nor staged by me).

    This was with 3.0.0.

    I'll try to reproduce with 3.0.2

  11. shivakumargarag commented on Jun 23, 2022

    @shivakumargarag

    Great! thanks for the update

  12. nikitaame commented on Jun 2, 2023

    @nikitaame

    Where on the product roadmap does this sit? This would greatly improve the workflow for our team!

  13. localota-travel commented on Oct 6, 2023

    @localota-travel

    I came from Perforce and really miss having my branches in different folders. It would be great if Github Desktop supported this.

  14. ShivamRawat0l commented on Jan 21, 2024

    @ShivamRawat0l

    One way you can use github workflow is by having the bare project.
    Github workflow adding the branches in the folder.
    Opening each folder separately as a repo in the github desktop application.
    Each one of them will have same name so just give them alias to identify the branch.

    I feel that this feature is more of a editor feature rather then github client because at the end of the day you will need to open that folder in the text editor. vscode and nvim has plugins for it but xcode 👎🏿

  15. 30 remaining items

  16. guplem commented on Mar 15, 2026

    @guplem

    In case you are willing to switch to a fork, this has already been implemented in GitHub Desktop Plus. It includes a worktree selector next to the branch selector, allowing you to view and switch between all your git worktrees within the same repository.

  17. boycce commented on Mar 25, 2026

    @boycce

    @guplem thank-you!!! Works amazing.

  18. devxoul commented on Mar 25, 2026

    @devxoul
    Contributor

    Yeah I built it on GitHub Desktop Plus and I'm totally migrated to it.

  19. removed
    not-planned
    on May 15, 2026
  20. niik commented on Jun 12, 2026

    @niik
    Member

    Hey folks watching this almost 10 year old issue! I'm excited to say that we've added support for Git worktrees into GitHub Desktop (built on top of @devxoul work) and that it's currently shipped to our beta channel. If you have time we'd really appreciate it if you could try it out and let us know what you think. We're hoping to release this to our production channel later this month.

    Given that this is now on beta and (barring any major feedback) is on its way to being released to production I'm gonna call this issue completed. If you have feedback please open a new issue for us to look at. Thanks!

  21. sandstrom commented on Jun 12, 2026

    @sandstrom

    @niik Awesome! 🇸🇪

    Is there any chance you'll let us configure where they are stored?

    Using worktrunk currently, and it has good support for configuration.

    Example

    Centralized worktree directory (~/code/worktrees/myproject/feature-auth):

    worktree-path = "~/code/worktrees/{{ repo }}/{{ branch | sanitize }}"
    

    Friendly name (~/code/worktrees/myproject/malleable-opah):):

    worktree-path = "~/code/worktrees/{{ repo }}/{{ branch | codename(2) }}"
    
    

    https://worktrunk.dev/config/#worktree-path-template

  22. niik commented on Jun 12, 2026

    @niik
    Member

    @sandstrom Interesting, currently the add worktree dialog lets you pick a base path and that will persist across multiple worktrees exactly like how the create repository dialog works (so it is shared across repositories). Would you mind opening a new issue for this so that we don't have to add to this issue?

  23. sandstrom commented on Jun 12, 2026

    @sandstrom

    @niik Added one here: #22308

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions