1

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?

dijxtra
  • 2,681
  • 4
  • 25
  • 37
  • possible duplicate of [Record file copy operation with Git](http://stackoverflow.com/questions/1043388/record-file-copy-operation-with-git) – Flexo Sep 14 '11 at 13:47

3 Answers3

2

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.

Abizern
  • 146,289
  • 39
  • 203
  • 257
0

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

MZimmerman6
  • 8,445
  • 10
  • 40
  • 70
0

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

Read git-subtree(1) manpage for details.

Jakub Narębski
  • 309,089
  • 65
  • 217
  • 230