开发者

How do I do copying in git?

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开发者_StackOverflow中文版 git.

So, how do I copy in git?


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.


you can use the $git clone commands to copy things from one place to another. Is that what you mean?


You can try git-subtree tool to help with splitting subdirectory into separate project.

Read git-subtree(1) manpage for details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜