Github,怎么把一个 repo 里的文件移动到另一个 repo 里?

2019-09-24 19:03:22 +08:00
 b00tyhunt3r

这居然查不到?????

3640 次点击
所在节点    程序员
8 条回复
MikeFeng
2019-09-24 19:47:07 +08:00
git 又不是给你当文件夹用的
hly9469
2019-09-24 19:50:40 +08:00
submodule ?
jinliming2
2019-09-24 20:05:07 +08:00
fork
git clone; git remote add; git push
orzorzorzorz
2019-09-24 20:07:12 +08:00
在目标文件夹里 clone 项目,然后 push 上去不就完了。要挑文件自己慢慢 add 去
airyland
2019-09-24 20:15:00 +08:00
其实你需求也没说清楚。
你要作文件移动操作默认就是复制粘贴了,你要让他们有依赖关系就是 submodule,不要怪 Github。
msg7086
2019-09-25 07:09:08 +08:00
两个仓库克隆下来,文件移过去,两边提交推送。
不知道有啥查不到的。
passion336699
2019-09-25 08:58:44 +08:00
可以用 git submodule

在主仓库根目录加上 submodule 配置文件: .gitmodules

里面大概像这样:

[submodule "src/subA"]
path = src/subA
url = http://xxx/subA.git
[submodule "src/subB"]
path = src/subB
url = http://xxx/subB.git

你想配置多个都可以, 第一次拉取主仓库的时候, 运行一下 git init submodule

后面更新主仓库的时候, 会自动 fetch submodule

不过每次 submodule 项目 push 之后, 主仓库, 你需要提交 submodule 的 commits 变化



说了很多, 反正 submodule 不好用.........
passion336699
2019-09-25 09:04:23 +08:00
对应的文件结构示例

repo

----.git/

----.gitmodules

----src/

--------subA/
--------subB/

-------- ....
--------repo other dirs/

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/603817

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX