制作本地 git 回购的本地副本
Make local duplicate of local git repo
我的本地计算机上有一个 git 存储库,我 需要 100% 在本地复制。
问题是我一直将我的本地存储库保存在同步我所有 PC 的保管箱中。今天 dropbox 决定最终搞砸 repo(是时候了)所以我很快断开了网络并启动了我的另一台 PC - 这个 repo 很好!
显然,作为一个没有经验的 git 用户,我 很长一段时间 都没有投入使用,所以还有很多工作要做机器。我需要在 dropbox 之外复制这个 repo,这样我就可以保存我的工作和分支,并推送到一个安全又安全的远程位置。
我已经尝试 git 使用几个不同的参数进行克隆,但我只设法克隆了一个分支。我看过 mirror 命令,但无法弄清楚。有帮助吗!?
您可能想要 git clone --mirror
。来自 git-clone man page:
--mirror
Set up a mirror of the source repository. This implies --bare. Compared to --bare, --mirror not
only maps local branches of the source to local branches of the target, it maps all refs
(including remote-tracking branches, notes etc.) and sets up a refspec configuration such that
all these refs are overwritten by a git remote update in the target repository.
复制目录也可以;但是,您必须确保您的副本还包括隐藏的文件和文件夹。 (即:调用 cp -R my-git-repo my-clone
而不是 cd my-git-repo; cp * ../my-clone
)。这也将复制您的工作树,这对于简单备份来说很好,但如果您打算从此副本克隆,则不可取。
正如用户 SLaks 所述:"Just copy the entire directory."
我的本地计算机上有一个 git 存储库,我 需要 100% 在本地复制。
问题是我一直将我的本地存储库保存在同步我所有 PC 的保管箱中。今天 dropbox 决定最终搞砸 repo(是时候了)所以我很快断开了网络并启动了我的另一台 PC - 这个 repo 很好!
显然,作为一个没有经验的 git 用户,我 很长一段时间 都没有投入使用,所以还有很多工作要做机器。我需要在 dropbox 之外复制这个 repo,这样我就可以保存我的工作和分支,并推送到一个安全又安全的远程位置。
我已经尝试 git 使用几个不同的参数进行克隆,但我只设法克隆了一个分支。我看过 mirror 命令,但无法弄清楚。有帮助吗!?
您可能想要 git clone --mirror
。来自 git-clone man page:
--mirror
Set up a mirror of the source repository. This implies --bare. Compared to --bare, --mirror not
only maps local branches of the source to local branches of the target, it maps all refs
(including remote-tracking branches, notes etc.) and sets up a refspec configuration such that
all these refs are overwritten by a git remote update in the target repository.
复制目录也可以;但是,您必须确保您的副本还包括隐藏的文件和文件夹。 (即:调用 cp -R my-git-repo my-clone
而不是 cd my-git-repo; cp * ../my-clone
)。这也将复制您的工作树,这对于简单备份来说很好,但如果您打算从此副本克隆,则不可取。
正如用户 SLaks 所述:"Just copy the entire directory."