How can I move a single directory from a git repository to a new repository whilst maintaining the history?

后端 未结 3 779
执念已碎
执念已碎 2020-12-04 06:35

I have inherited a git repository containing multiple projects in separate directories. I\'d like to split the repository into new individual repositories, one for each proj

3条回答
  •  温柔的废话
    2020-12-04 07:13

    To export a folder as a new repository you need:

    1. To clone the repository where the folder you want to export is.
    2. To create a empty repository on your hosting provider as GitHub, to store the exported folder.
    3. Open the cloned repository folder and run this command:

      git subtree push --prefix=YourFolderNameToExport https://github.com/YourUserName/YourNewCleanRepoName master
      

提交回复
热议问题