如何更改git目录

时间:2019-02-07 16:11:32

标签: git

我在一个子文件夹中有一个可用的git存储库,现在我还希望其中包含基础文件夹。

例如

我的存储库位于:

/var/dir/working/

现在我也想将其包含在仓库中

/var/dir/

如何以最简单的方式实现?

1 个答案:

答案 0 :(得分:0)

我不确定最简单的方法是否是将.git文件夹更改为应有的位置。

cd /var/dir/working/
mv .git ../.git # move the .git folder to the parent directory
cd .. # go to parent directory
git status # then you can see a lot of delete and untracked
git add . # output nothing
git status # after add all, you can see those delete and untracked are converted
           # to renaming, and some untracked from "parent directory"
git commit -m "Include parent directory" # you may see a lot of renaming,
                                         # and new file from parent dir, that's it