Answers:
非常简单 Git不在乎目录的名称。它只关心里面的东西。因此,您可以简单地执行以下操作:
# copy the directory into newrepo dir that exists already (else create it)
$ cp -r gitrepo1 newrepo
# remove .git from old repo to delete all history and anything git from it
$ rm -rf gitrepo1/.git
请注意,如果存储库很大且历史悠久,则副本非常昂贵。您也可以轻松避免它:
# move the directory instead
$ mv gitrepo1 newrepo
# make a copy of the latest version
# Either:
$ mkdir gitrepo1; cp -r newrepo/* gitrepo1/ # doesn't copy .gitignore (and other hidden files)
# Or:
$ git clone --depth 1 newrepo gitrepo1; rm -rf gitrepo1/.git
# Or (look further here: http://stackoverflow.com/q/1209999/912144)
$ git archive --format=tar --remote=<repository URL> HEAD | tar xf -
创建后newrepo,放置目的地gitrepo1可以在任何地方,即使newrepo您愿意也可以放置在内部。它不会改变过程,只会改变您正在gitrepo1回写的路径。
cp就像几乎每个命令或功能都特定于其他操作系统一样。实际上,它特定于不是Windows的每个操作系统。尝试致电Microsoft,并询问他们为什么不是POSIX。无论如何,cp意味着复制。mv意味着移动。rm表示删除。您可以找到等效的Windows。
.git/包含所有历史记录,其中包括您的最新提交。无论放在哪里,都拥有所有的历史。实际上,如果该目录中的所有文件都与您从中获取的原始存储库不同.git/,那么唯一的事情就是它会告诉您某些文件已被删除而一些未跟踪的文件存在。使用git reset --hard,删除的文件将自动恢复!唯一需要注意的是,仅通过复制.git/就无法恢复未提交的更改。
mv girepo1 newrepo??