Git跟踪的文件夹中的Git跟踪的文件夹 [英] Git-tracked Folder Within a Git-tracked Folder

查看:333
本文介绍了Git跟踪的文件夹中的Git跟踪的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个web项目并使用git进行跟踪。后来我不得不在另一个大型项目中使用该项目,这个项目又被git跟踪。之前我没有关于git子模块的知识。所以我马上将小型项目文件夹复制到大型项目文件夹中。然后,当我将大项目推送到远程存储库时,我注意到远程仓库正在将小项目链接到其各自的远程仓库。如果我在大项目中的小项目中更改了任何内容,那么它不会被跟踪。我认为问题是小项目中的.git文件夹,所以我删除了该文件夹。现在我甚至无法推到小型项目的远程回购。有没有解决方案?我可以取消我所做的一切,以便我可以让小项目成为大项目的git子模块吗? 解决方案


如果我在大项目中的小项目中更改了任何内容,那么它不会被跟踪。


它并未被追踪,因为它被父项目视为 嵌套回购协议 。如果您的第一个仓库被推送到远程的某个地方,那么您可以将它添加为子模块。 您使用 git submodule add

  cd second / big / repo 
git submodule add - / url / first / repo

如果不是,则需要重新创建第一个回购( outside )大回购),把它推到远程的地方(GitHub,GitLab,Bitbucket,...),并把它作为你的大回购的子模块。


I developed a web project and tracked it with git. Later I had to use that project in another big project which is again tracked by git. Earlier I didn't have knowledge about git sub module. So I straight away copied the small project folder into the big project folder.

Then when i pushed the big project to the remote repository, I noticed that the remote repo is linking the small project to its respective remote repo. If I change any thing in the small project within the big project, it is not getting tracked. I thought the problem is the .git folder in the small project, so I deleted that folder. Now I can't even push to the small project's remote repo. Is there any solution for this? Can I undo everything I have done so that I can make the small project to be the git sub module of the big project?

解决方案

If I change any thing in the small project within the big project, it is not getting tracked.

It is not being tracked because it was seen by the parent project as a gitlink for nested repo. That is, just a SHA1, not its actual content.

If your first repo was pushed somewhere remote, then you could add it as submodule of your main repo with git submodule add.

cd second/big/repo
git submodule add -- /url/first/repo

If not, you would need to recreate your first repo (outside the big repo), push it somewhere remote (GitHub, GitLab, Bitbucket, ...) and add it as submodule of your big repo.

这篇关于Git跟踪的文件夹中的Git跟踪的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆