Git clone without .git directory

后端 未结 4 1473
离开以前
离开以前 2020-12-02 04:39

Is there a flag to pass to git when doing a clone, say don\'t clone the .git directory? If not, how about a flag to delete the .git di

4条回答
  •  隐瞒了意图╮
    2020-12-02 05:25

    Use

    git clone --depth=1 --branch=master git://someserver/somerepo dirformynewrepo
    rm -rf ./dirformynewrepo/.git
    
    • The depth option will make sure to copy the least bit of history possible to get that repo.
    • The branch option is optional and if not specified would get master.
    • The second line will make your directory dirformynewrepo not a Git repository any more.
    • If you're doing recursive submodule clone, the depth and branch parameter don't apply to the submodules.

提交回复
热议问题