Git & Intellij, How do I commit only parts of a changed file

GitIntellij IdeaGit Commit

Git Problem Overview


I can't seem to commit only a fraction of the changes in a file, it seems to be all of the file or nothing, I'm using Git with Intellij, is it possible?

Thanks.

Git Solutions


Solution 1 - Git

Update - 2/2018: The first EAP build for 2018.1 has landed and it's HERE! It is implemented as checkboxes for each hunk, so you can selectively check on them before making the commit. Enjoy!

Update - 12/2017:

Well 2017.3 was just released and this didn't make it in. So let's hope for 2018.1.

Update - 11/2017:

This has been 'in progress' for months now. The 2017.3 EAP releases have been coming out for a while but this issue hasn't been finished yet. With no updates to the issue other than people asking when it will be done, I'm thinking this will slip to the 2018 release.

Update - 2017:

This issue has been open for years as noted in some of the comments. But it is now in progress and sheduled to land in 2017.3 which is currently in EAP release and should be available this fall. So now, four years after this was asked, you will soon be able to actually do it right in the IDE.

Solution 2 - Git

Not in the IDE. As noted in comments, you can use the command line, but I find it much easier to use a GUI GIT client (I use Tower, but there are many available).

Solution 3 - Git

You should try SourceTree(Mac & Windows), It's free and a great tool for working with GIT. It has all the commit freedom you want in a confortable UI.

This is my commit workflow for IntelliJ, from simple to complex task:

  1. IntelliJ
  2. SourceTree
  3. shell GIT.

Solution 4 - Git

The wait is finally over, partial commits are part of EAP 18.1: https://blog.jetbrains.com/idea/2018/02/intellij-idea-2018-1-eap-partial-git-commits-and-more/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJordanView Question on Stackoverflow
Solution 1 - GitSean LynchView Answer on Stackoverflow
Solution 2 - GitkhaglerView Answer on Stackoverflow
Solution 3 - GitAndres CanellaView Answer on Stackoverflow
Solution 4 - GitDavid LeitnerView Answer on Stackoverflow