Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use git worktrees in IntelliJ IDEA 2016.1?

The newest version of IntelliJ says it has support for git worktrees, but I can't seem to find anywhere that says how to use it. I was expecting to see an entry in the Git Branches popup in the lower right, but I don't see it there.

I also don't see any descriptions in:
Blog post announcing the feature
What's new video

IntelliJ help and googling were also unhelpful

I'm using Git version 2.7.2.0, worktrees were introduced in 2.5

like image 204
DanTilkin Avatar asked Apr 05 '16 22:04

DanTilkin


People also ask

How do I get Git options in IntelliJ?

Open the project that you want to put under Git. Press Alt+` to open the VCS Operations Popup and select Enable Version Control Integration. Alternatively, from the main menu, select VCS | Enable Version Control Integration. Choose Git as the version control system and click OK.

How do I change my Git repository URL in IntelliJ?

VCS - > Git - > Remotes Popup will open with all repository URLs configured, you can simply edit them or add new one. Save this answer.

How Commit and push your code in Git using IntelliJ?

Do one of the following: To push changes from the current branch press Ctrl+Shift+K or choose Git | Push from the main menu. To push changes from any local branch that has a remote, select this branch in the Branches popup and choose Push from the list of actions.


1 Answers

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

With 2016.1, however, you can open the worktree as a new project and perform all VCS operations via IntelliJ.

It would be nice to have project settings shared for those of us that .gitignore them, but that does not appear to be supported currently.

I have been using the following workflow recently with success:

  1. git worktree add ../hotfix hotfix/1.2.3
  2. File -> Open in IntelliJ
  3. Manually copy all Run Configurations over to the new .idea directory (if necessary)
like image 139
sarumont Avatar answered Sep 20 '22 12:09

sarumont