Problem
I have a git repo with two subdirectories under the root :/a
and :/b
, and I want to copy all versioned files from :/a
into :/a-copy
.
Essentially, I'd like to do
git mv a a-copy
without actually moving a
.
More Details
There are also many non-versioned files in :/a
, and I don't want to delete them, so I can't simply do
git clean -df a
cp -r a a-copy
The best workaround I've found (on Linux) is
mkdir a-copy
cd a
git ls-files -z | xargs -0 -i cp --parents {} ../a-copy
but I hope there is a simpler way.
Is This Question a Duplicate of "Do a “git export” (like “svn export”)?"?
That question is similar, but it only covers the case of copying/exporting the entire repo. I only want to copy part of the repo, i.e. the files under :/a
, and not also the files under :/b
. I read that question and its answers before posting this question. Now that I have an answer to my question, I see that the git archive
based solutions to that other question also solve my problem here.