Reputation: 2751
How do you copy a file or a directory with git, preserving revision history? I can't seem to find a way to do it.
What I'd like to do is to split a project into a library and GUI part (now they are mixed in the same project). So I'd like to copy a whole project, and then remove GUI parts from library project, and library parts from GUI project, but preserving the history of every file. It seems trivial undertaking, but I can't find the copy command in git.
So, how do I copy in git?
Upvotes: 1
Views: 353
Reputation: 323982
You can try git-subtree tool to help with splitting subdirectory into separate project.
Read git-subtree(1) manpage for details.
Upvotes: 0
Reputation: 150755
There is a handy guide at GitHub which describes how to split a subpath into a new repository.
So, you could git mv
the code that you want to split out into it's own directory, and use this method to create a new repository based on that folder, which will keep the history of the files intact.
Upvotes: 2
Reputation: 8623
you can use the $git clone commands to copy things from one place to another. Is that what you mean?
Upvotes: 0