84

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.

2

4 Answers 4

52

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.

5
  • so now we just have to wait for it to become true and then for all the great IntelliJ apps to rebase to 2017.3 core :) Can't wait!
    – Krystian
    Commented Oct 21, 2017 at 9:54
  • 1
    I wanted to come here and add a comment about 2018.1 but you beat me to it :) Anyway, finally git add -p in IDEA has come!
    – Minh Thai
    Commented Apr 3, 2018 at 9:32
  • would be nice to somehow never commit debugger lines in js
    – Keegan 82
    Commented Apr 10, 2018 at 12:41
  • @Sean yes but we cannot edit an hunk and then commit it. I think we can only either accept or reject a hunk ? So, git add -p will still be needed as such
    – Number945
    Commented Apr 20, 2018 at 10:44
  • 1
    Is there a way to remember lines which I selected? It could be a very nice feature Commented May 3, 2018 at 12:57
32

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).

3
  • 28
    That's a real shame. It's a prominent use case in my git workflow. For now, I use "git add --patch".
    – starmonkey
    Commented Sep 13, 2013 at 0:56
  • 2
    For reference, after using git add --patch and selecting the hunks you want, you run git commit -m XXX to actually commit it.
    – rogerdpack
    Commented Apr 25, 2016 at 19:17
  • 1
    As of 2018, Tower is available in full release for Windows.
    – David Gay
    Commented Jan 24, 2018 at 15:14
9

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.
0
5

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/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.