`git cp` command that can copy only tracked files, like `svn cp`

gitsvn

Unlike Subversion, git has no cp command. For files, this is not a problem: if I want to copy a file a to b, I can just do:

cp -a a b
git add b

However, say I want to copy a directory d to give it another name e. I can still do the same thing. However, d may contain files that are not tracked by git, e.g., compiled binaries, etc. In this context, I do not want to do the above, because I do not want git to track these additional files.

With Subversion, I can do svn cp, and it will only copy and add the files that are tracked by Subversion. How can I do this with git?

Best Answer

You can use git clone:

$ git clone /path/to/project /target/path

Then remove the .git file

$ rm -R /target/path/.git
Related Question