首页 > 解决方案 > 将 git hub 存储库更改为主文件夹(iso 子文件夹)

问题描述

我对 git hub 还很陌生,我正在与两个人一起在一个存储库上工作。目前我在以下位置有一个(本地)存储库:

C:\Users\Name\main_folder\sub_folder_9\

现在,main_folder里面有很多子文件夹。我们现在只共享/推送 中的信息sub_folder_9,但我们想向上“移动”目录。所以我们想在 中建立一个存储库main_folder,这样每当我们使用 Git Bash 时,所有子文件夹都会被推送和拉取。而且我们希望使用我们目前拥有的相同存储库(在 github.com 站点上),因此我们不必设置新的存储库。

我怎样才能做到这一点?

我知道我可能使用了错误的措辞,对此我很抱歉,但我希望我的问题仍然有意义。

标签: gitgithub

解决方案


正如您在评论中所说:是的,您可以将.git文件夹向上移动一级,然后推送。

更确切地说 :

# move the .git folder one level up :
mv .git ../
cd ../

# if you want, you can create a separate commit which clearly moves only sub_folder_9 :
git add sub_folder_9
git commit

# add the remainder of your main_repo folder :
git add *
git commit

然后推。


推荐阅读