git clone, ignoring a directory

后端 未结 4 1614
名媛妹妹
名媛妹妹 2020-11-30 03:31

I\'m trying to test something on a wordpress install. In doing so, I\'d like to quickly replicate the repo. However, the upload directory (wp-content/uploads) i

4条回答
  •  独厮守ぢ
    2020-11-30 04:14

    On the server:

     git checkout master^0    # the ^0 checks out the commit itself, not the branch
     git filter-branch --tree-filter 'git rm -r wp-content/uploads' HEAD
     git checkout -b filtered
    

    (filter-branch on a big project here generates new history at about 2-3 commits per second)

    Then, anywhere you like,

     git init
     git remote add gimme your://repo/path
     git fetch gimme filtered
    

    edit: fixed syntax errors according to http://git-scm.com/docs/git-filter-branch

提交回复
热议问题