--not D
git filter-branch ... D..H --not C</pre>
</div>
</div>
<div class="paragraph">
<p>To move the whole tree into a subdirectory, or remove it from there:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>git filter-branch --index-filter \
        'git ls-files -s | sed "s-\t\"*-&amp;newsubdir/-" |
                GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
                        git update-index --index-info &amp;&amp;
         mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD</pre>
</div>
</di