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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-04-04 11:06:49 +0000
Seen: 3 times
Last updated: Apr 04
What is the relationship between the backlog and the dependencies in Azure DevOps?
Git: Is it a good Idea to add the same Submodule multiple times as Submodule a Submodule?
How can I speed up a large Git Repository with lots of Directories?
How can I check out a Branch in Git?
Is it possible to refresh the index when Git stash pop requires merging?