Commit Only Selected Files in TortoiseGit
Commit a subset of modified files in TortoiseGit while leaving others uncommitted in the working tree.
17 Dec 2025, 22:26 UTC

Desired outcome
You have edited several files in a Git working tree, but only some are ready to share. You want to commit that subset now and leave the rest modified and uncommitted, without using Git command-line index commands.
Useful takeaway: In Windows Explorer, right-click a modified file or the repository folder, choose TortoiseGit > Git Commit..., clear the checkboxes for files you want to leave out, enter a commit message, and commit. The unchecked files stay modified in the working tree and remain excluded from that commit.
Prerequisites
- Windows with TortoiseGit 2.x and Git for Windows 2.x installed.
- A local Git repository with a working tree checked out.
- One or more modified, added, or deleted files in that working tree.
- Read and write permission for the repository directory.
The commit dialog works at file granularity. It cannot select individual hunks inside a single file. If you edited unrelated changes in the same file, you must split them outside TortoiseGit or commit the whole file.
Procedure: commit only selected files
- Open Windows Explorer and navigate to the repository working tree.
- Right-click a modified file, or right-click the folder containing the modified files, and choose TortoiseGit > Git Commit.... The Commit dialog opens.
- Review the file list. Each changed, added, or deleted file has a checkbox. Checked files will be included in the commit.
- Clear the checkbox for every file you want to leave uncommitted. Those files remain modified in the working tree; they are not staged or stashed.
- To verify a file’s contents before including it, double-click the file in the list to open the diff viewer.
- Enter a commit message in the message box at the bottom of the dialog.
- Click OK or Commit to create the commit with only the checked files.
Expected checks
- After the commit, Windows shell status overlays still show the unchecked files as modified.
- Opening the Commit dialog again lists the unchecked files among the pending changes.
- Run
git statusin the repository root to confirm uncommitted changes remain. - Run
git log --stat -1to confirm only the intended files appear in the latest commit.
# Run in Git Bash or Command Prompt from the repository root. # Requires read access to inspect state; write access is needed only to commit. git status git log --stat -1
Placeholder meaning: run these from your actual repository root path. These commands read repository state and do not modify files.
Risks and limitations
- Excluding a file does not protect it from being committed later. If you open the Commit dialog again and leave it checked, it will be included in the next commit.
- File-level selection only. Partial-file commits require external tools or manual editing before the commit.
- Omitting dependent changes can leave the working tree inconsistent with the branch. Build or test affected code before pushing if you left related changes uncommitted.
Recovery if you commit the wrong files
Committing changes repository state, so undoing it is a state-changing operation.
- To undo the most recent commit while keeping its changes in the working tree, run
git reset --mixed HEAD~1in the repository root. You can then recompose the commit with the correct file selection. Do not use this on commits already pushed to a shared repository, because it rewrites history. - To create a new commit that reverses the unwanted changes without rewriting history, run
git revert HEAD. This is safer for pushed commits. - To restore one specific file to its state in the previous commit, run
git checkout HEAD~1 -- path/to/file, replacingpath/to/filewith the relative path, then commit the restoration.
Practical verification: After recovery, run git status and git log --stat -1 again. The working tree should contain only the changes you intend to keep uncommitted or recommit.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.