Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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) is massive, so I'd like to ignore it.

Note: I don't want to .gitignore this directory all the time, just for this scenario.

Basically, I'd like a command like this pseudo code: git clone --ignore wp-content/uploads.

Is the best way to add that directory to .gitignore, clone, and then revert .gitignore? Or is there a better method?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
534 views
Welcome To Ask or Share your Answers For Others

1 Answer

A bit late to the party, but: Don't you want a sparse checkout?

mkdir <repo> && cd <repo>
git init
git remote add –f <name> <url>

Enable sparse-checkout:

git config core.sparsecheckout true

Configure sparse-checkout by listing your desired sub-trees in .git/info/sparse-checkout:

echo some/dir/ >> .git/info/sparse-checkout
echo another/sub/tree >> .git/info/sparse-checkout

Checkout from the remote:

git pull <remote> <branch>

See http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/ for more info.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...