Work on a Git project can leave several unrelated edits in the same working tree. The Git Staging view in Eclipse on the Linux desktop lets you choose which saved changes go into a local commit.

Staging copies a file's current contents into the Git index. If you edit the file again after staging it, the newer edits stay in the working tree until you stage them too.

Each commit records a message and a Git identity in the history of the checked-out branch. Pushing is a separate operation that sends local commits to a remote repository.

Start with Project Explorer visible in Eclipse with EGit installed, a Git project on the branch you intend to commit to, saved file changes, and your Git name and email configured. The file filter should be off in Git Staging, with the funnel button at the top unpressed and no filter field showing. The Commit Message box should be empty. If Eclipse shows Install Java 27 Support, you can choose whether to install it. Continue at step 1 with the workbench open.

Steps to commit Git changes in Eclipse:

  1. Select your Git project in Project Explorer.

    The pictures use the hello Java project in ~/eclipse-workspace on the main branch. Your project and branch names will appear in the same place.

  2. Open Window from the Eclipse menu bar.
  3. Point to Show View in the Window menu.
  4. Choose Other… from Window > Show View.
  5. Enter Git Staging in the filter at the top of the Show View dialog.
  6. Click Open with Git Staging selected.

    The view header names the repository and branch that will receive the commit. If either differs from the one you intend to use, stop before staging.

  7. Drag the divider above Git Staging upward if the view is too short to show its lists and buttons.
  8. Select the file you want to commit under Unstaged Changes.

    The file selected here is README.md. The other edited file, NOTES.md, stays unstaged.

  9. Click Add selected files to the index, the green plus above Unstaged Changes.
  10. Check that Staged Changes lists only the files you intend to commit.

    The commit will include every staged file in the repository. If Staged Changes includes any unrelated files, stop before committing.

  11. Click inside Commit Message.
  12. Set Commit Message to a short description of your change, such as Document how to run Hello.

    The Commit and Push… button also attempts to send commits to a remote.

  13. Click Commit in Git Staging to save the staged changes to the local branch.

    A successful local commit clears the Staged Changes list.

  14. Right-click the project in Project Explorer.
  15. Point to Team in the project context menu.
  16. Choose Show in History from Team.
  17. Select the commit in History that matches your message and shows your intended branch name beside HEAD if it is not already selected.
  18. Verify that the changed-file list for your new commit in History matches what you staged.

    The Document how to run Hello commit is marked HEAD on main and lists only README.md in the lower-right pane.

Share this guide