To commit specific files from a subdirectory in Git, you can use the
git add command followed by the path to the specific files you want to commit. You can use either relative or absolute paths to specify the location of the files.
Here's an example of how you might use the
git add command to commit specific files from a subdirectory:
git add <subdirectory>/<file1> <subdirectory>/<file2>
For example, if you have a subdirectory called "src" and you want to commit two files called "main.c" and "main.h", you would use the following command:
git add src/main.c src/main.h
Alternatively, you can also use wildcards to add multiple files with a similar name or pattern in the subdirectory, for example:
git add src/*.c
This will add all files with the
.c extension in the
After that you can use
git commit -m "<message>" as usual to create a new commit with the specified commit message. The commit message should briefly describe the changes that were made in this commit.
It's important to note that if you haven't added the files yet, this command will only stage the files for commit and will not actually commit them. You need to use
git commit command separately.