Several edits can share a working tree even when they belong in different commits. In IntelliJ IDEA on the Linux desktop, the Commit tool window lets you review changes file by file and record the ones that belong together in a Git commit.

The diff compares your working copy with the version already in Git. A quick look at both versions can catch an unfinished edit or content you didn't mean to include.

A local commit records the checked changes on the current branch. Unchecked changes stay in your working tree for later. The changelist layout and the Git log are also available in PyCharm.

Steps to commit changes in JetBrains IDE:

Start with your Git project open on the branch you want to commit to, with a Git author name and email configured and changes to tracked files. Both the Commit and Git tool windows start closed. Commit uses changelist checkboxes with Amend turned off, and Git opens on Log. The example uses ~/IdeaProjects/hello on branch main, with changes to README.md and NOTES.md.

  1. Open the Commit tool window with Alt+0.

    If the editor shows Air or a Junie offer, either can stay open while you use Commit.

  2. Select the file you want to review under Changes, such as README.md.
  3. Open the selected file's diff with Ctrl+D.
  4. Review the diff with the committed version on the left and your working version on the right.
  5. Set the checkboxes under Changes so only the files you want to commit are checked.

    In the example, only README.md goes into the commit.

  6. Click inside the Commit Message field.
  7. Select the existing message with Ctrl+A if the field contains text.
  8. Enter a commit message that describes your changes, such as Describe Java demo.
  9. Click Commit to record the selected changes in your local repository.
  10. Open Git from the lower-left tool window bar once the committed files disappear from Changes.
  11. Select the new commit with your message at the top of your branch in Log.
  12. Verify that the selected commit's file list contains exactly the files you chose.

    The example commit lists only README.md.

Share this guide