警告!通过对父母进行结帐丢失了嵌套的儿童回购 [英] Caution! Just lost nested child repo by doing checkout on parent
问题描述
-Repo A
| - .git
| - files
| - 回购B
| - .git
| - 文件
然后,我随即在回购A上检查了一个不同的分支(只需在Github中为Mac切换分支),立即切换回来,并且:
-Repo A
| - .git
| - 文件
| - 回购B
回购B在那里但是空的!甚至没有.git目录!
没有遥控器,并且进行了2周的3D建模。
(讽刺的是,我的第一个3D模型(在所有这些之前)变得腐败了,所以我想我会使用git并定期提交,所以我做了...)
嵌套的git仓库只记录为 gitlink ,这是主要存储库的特殊索引条目。 p>
当您结账回原始分支时,Git会恢复gitlink,但不知道SHA1来自哪个回购。
要保留SHA1 和内容,您需要将repo B
声明为 submodule 。
然后你会有一个 .gitmodules
文件i n主要的回购 A
,它会记录回购 B
远程原始网址。
Up until recently, I had this file structure:
-Repo A
|- .git
|- files
|- Repo B
|- .git
|- files
I then casually checked out a different branch on Repo A (simply switched branches in Github for Mac), immediately switched back, and voilà:
-Repo A
|- .git
|- files
|- Repo B
Repo B is there but empty! Not even a .git directory!
No remotes, and there goes 2 weeks of 3D modelling.
(The irony of it all is that my very first 3D-model (before all of this) went corrupt so I figured I'd use git and commit on a regular basis. And so I did...)
A nested git repo is only recorded as a gitlink, that is a special entry in the index of the main repo.
When you checkout back to your original branch, Git restores the gitlink, but has no idea to which repo that SHA1 is coming from.
To keep both SHA1 and content, you would need to declare repo B
as a submodule.
Then you would have a .gitmodules
file in the main repo A
, which would keep a record of the repo B
remote origin url.
这篇关于警告!通过对父母进行结帐丢失了嵌套的儿童回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!