Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To commit only files that were modified in Git, and not include files that were deleted, you can use the following command:

git commit -m "commit message" $(git ls-files -m)

The git ls-files -m command lists all files that have been modified. The $(git ls-files -m) expression substitutes the output of the git ls-files -m command as arguments to the git commit command. This means that only the modified files will be included in the commit.

Note that this command will only commit modified files that are already tracked by Git. If you have new files that you want to include in the commit, you will need to use git add to stage them first. Also, if you have deleted files that you want to exclude from the commit, you will need to use git reset or git checkout to unstage or discard the changes to those files.