简体   繁体   English

将子目录复制到同一个 git repo 中的另一个文件夹中

[英]Copying a subdirectory into another folder in the same git repo

Current local git repo structure当前本地 git repo 结构

As per the screenshot: I have a local git repo called fso_test, which has subfolders called "part3" and "part4".根据屏幕截图:我有一个名为 fso_test 的本地 git 存储库,其中包含名为“part3”和“part4”的子文件夹。

Part3 currently contains the root directory of an express app, called "notes-backend". Part3 当前包含一个名为“notes-backend”的 express 应用程序的根目录。

I'd like to continue working with "notes-backend" in part4, so I need to move it to part4.我想继续在第 4 部分中使用“notes-backend”,因此我需要将其移至第 4 部分。 I've encountered numerous problems in doing so.我在这样做时遇到了很多问题。 I've tried crude approaches such as literally copying and pasting "notes-backend" into part4, as well as more sophisticated approaches .我尝试过粗略的方法,例如将“notes-backend”字面复制并粘贴到第 4 部分,以及更复杂的方法

I've excluded much of the directory structure for simplicity.为简单起见,我排除了大部分目录结构。

Any advice?有什么建议吗?

EDIT: When I tried cp -r notes-backend ../part4 while in part3, and then tried to stage the changes for commit, I received an error saying "warning: adding embedded git repository: course_content/part4/notes-backend".编辑:当我在第 3 部分中尝试cp -r notes-backend ../part4 ,然后尝试暂存更改以进行提交时,我收到一条错误消息:“警告:添加嵌入式 git 存储库:course_content/part4/notes-backend” .

If you want to copy the directory, run this from the repo root :如果要复制目录,请从 repo root运行:

cp -r course_content/part3/notes-backend course_content/part4/notes-backend
git add .
git commit -m "Copy notes backend to part4"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM