我有一个gitrepo1目录。这个目录是一个git存储库。
newrepo.
我该怎么做呢?
发布于 2013-09-30 22:50:38
这很简单。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的路径。
发布于 2020-02-23 12:35:51
它甚至比这更简单。我只是做了这件事(在Windows上,但它应该可以在其他操作系统上工作):
Git只看到你添加了一个目录并重命名了一堆文件。没什么大不了的。
发布于 2020-07-16 20:48:42
我不是专家,但我会将.git文件夹复制到一个新文件夹中,然后调用:git reset --hard
https://stackoverflow.com/questions/19097259
复制相似问题