Search code examples
gitarchivecp

git-archive vs. cp


What is the advantage of using

git archive master/foo | tar -x -C ~/destination

to deploy a copy of /foo vs. just copying from the the working copy with

cp foo ~/destination/foo

So, unless for some reason you don't want to copy everything over from that sub directory foo in master (or whatever branch you happening to be working on), using cp for deploying to a [destination] would suffice.


Solution

  • git archive only exports items that are part of the git repository. cp copies everything that's under the specified directory, including the .git directory, files which are ignored by git, etc.