How to use git worktrees in IntelliJ IDEA 2016.1?

The newest version of IntelliJ says it has git worktrees support, but I can't find anywhere where it says how to use it. I was expecting to see the entry in the git popup in the lower right, but I do not see it there.

I also do not see any descriptions in:
Blog post announcing feature
What new video

IntelliJ help and googling were also useless

I am using git version 2.7.2.0, working lines were introduced in 2.5

+6
source share
2 answers

As far as I can tell, "support" means that when you open the working line in IntelliJ, all VCS functions work correctly. Based on the comments in the Youtrack link provided by max630, you could not view the changes, view the history, or commit the changes until 2016.1.

As of 2016.1, however, you can open worktree as a new project and perform all VCS operations through IntelliJ.

It would be nice to have project options for those of us that .gitignore them, but they are not currently supported.

Recently, I have successfully used the following workflow:

  • git worktree add ../hotfix hotfix/1.2.3
  • File -> Open in IntelliJ
  • Manually copy all Run Configurations to the new .idea directory (if necessary)
+8
source

The most likely reason for this: git worktree add uses absolute default paths, so if you run it from bash (Git for Windows or WSL), the path will be invalid for the 'git windows:

C:\code\worktree-repo>git status fatal: Not a git repository: /mnt/c/code/original-repo/.git/worktrees/worktree-repo

You can fix this by updating the path in the worktree .git file (and not in the directory for working trees!) With respect to:

C:\code\worktree-repo>type .git gitdir: ../original-repo/.git/worktrees/worktree-repo

You also need to update .git/worktrees/worktree-repo/gitdir to be relative, so windows git in the source repo knows how to find the working line, but this is less important (AFAIK, it prevents the git worktree prune from being dropped and from checking the same branch in source repo)

0
source

All Articles