Reputation: 43547
Usually I use git commit -a
or git add -a
to quickly add all of the files which are in the repo, which have been changed.
At times I want to commit a subset of what was changed. Here we specify them explicitly.
But I want to do something more nuanced now: Suppose my git repo has two sub projects inside of it and i want to make a commit for sub-project A, where I have inside the A/
dir (1) a bunch of temporary files not checked into git and which I do NOT want to add to the index, and (2) multiple files which have been checked in which have changed, which I want to add to the index in one fell swoop of a command.
I am aware that if I modify my gitignore to fully encapsulate all possible types of temporary files, then I may use add -a
to achieve this easily. However this isn't really very practical because directories tend to accumulate "extra items" in them.
Does such a git command exist?
Upvotes: 0
Views: 84
Reputation: 793109
Update all tracked files in A:
git add -u A
From documentation:
-u, --update
Update the index just where it already has an entry matching
<pathspec>
. This removes as well as modifies index entries to match the working tree, but adds no new files.If no
<pathspec>
is given when-u
option is used, all tracked files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).
Upvotes: 2