You just have to take the exact content of D
, and create a commit with that content :
# choose a. or b. :
# a. 'git restore' was added for this purpose in version 2.25,
# and has options which are more explanatory (readable at least) :
git restore --source D --staged --worktree -- .
# b. for older gits, or for people enjoying more obscure commands, there is 'git read-tree' :
git read-tree D
# after that :
# confirm that the content you expect is staged, and commit :
git status
git commit
one word of caution: git restore
with the --worktree
option can delete files and discard modifications from files that aren't stored in git
yet -- much like git reset --hard
.
It is advised to use this command on a clean worktree, or at least check that you can throw away your current modifications.