我需要git包含父目录 [英] I need git to include the parent directory

查看:77
本文介绍了我需要git包含父目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个分为3个程序包的程序.我已经在其中一个软件包中设置了本地存储库,并将其设置为推送到gitHub上的存储库.我已经开始研究第二个软件包,但我意识到我还没有使用git对其进行初始化.我想使用相同的gitHub存储库将第二个程序包推送到其中,但是由于我已经设置了第一个程序包以推送到它,所以我不确定它是否可以正常工作.我认为我应该在三个软件包的父文件夹上执行git init,然后该文件夹/软件包结构将显示在我的gitHub存储库中.有一种简单的方法可以解决此问题吗?谢谢!

I have a program divided into 3 packages. I have set up a local repo in one of the packages and set it up to push to a repo on gitHub. I have started work on the second package and I realized I haven't initialized it with git. I wanted to use the same gitHub repo to push the second package to but I'm not sure it will work since I have already set up my first package to push to it. I think I should have done git init on the parent folder of the three packages and then the folder/package structure would have shown up on my gitHub repo. Is there a simple way to fix this? Thanks!

推荐答案

假设您的父目录命名为parent,子目录命名为package1package2package3.我们还假设package1是您的git存储库所在的目录.我只是将另一个 package1目录作为原始package1目录的子目录,然后将原始package1目录的内容移入其中.然后将package2package3移为原始package1的子级.您可以将原始package1重命名为parent. git add --all .整个过程,您现在拥有一个包含所有三个目录的存储库.很棒的事情是您不会丢失所有移动文件的历史记录; git足够聪明,可以检测到重命名/移动.

Let's say your parent directory is named parent, and your child directories are named package1, package2, and package3. Let's also assume that package1 is the directory where you have your git repository. I would just make another package1 directory as a child of the original package1 directory, and move the contents of the original package1 directory into it. Then move package2 and package3 to be children of the original package1. You can the rename the original package1 to parent. git add --all . the whole thing, and you now have a repo with all three directories. The cool thing is that you will not lose the history of all the files you moved; git is smart enough to detect renames/moves.

这篇关于我需要git包含父目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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