มันง่ายมาก 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กลับ
mv girepo1 newrepo??