Clone git repository without history?

后端 未结 3 1531
你的背包
你的背包 2020-12-29 01:32

I wanted clone repository from github. It had lot of history, So i wanted clone without any history.

Is it possible to clone git repository without history?

相关标签:
3条回答
  • 2020-12-29 02:14

    Use the --depth option in git clone:

    --depth <depth> Create a shallow clone with a history truncated to the specified number of revisions.

    Usage: git clone --depth 1 <remote_repo_url>

    0 讨论(0)
  • 2020-12-29 02:15

    You can get a shallow clone using the --depth option with value 1

    git clone --depth 1 reponame.git
    

    If you want more commit history, increase the value to meet your needs as required.

    0 讨论(0)
  • 2020-12-29 02:33

    After cloned, you can delete the .git directory, then re-init the git to generate a totally new repo.

    $ git clone ...
    $ cd path/to/repo
    $ rm -rf .git
    $ git init
    
    0 讨论(0)
提交回复
热议问题