git clone,忽略一个目录 [英] git clone, ignoring a directory

查看:665
本文介绍了git clone,忽略一个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在wordpress安装上测试一些东西。这样做,我想快速复制回购。然而,上传目录( wp-content / uploads )非常庞大,所以我想忽略它。



<注意:我不希望这个目录始终存在,只是针对这种情况。



基本上,我想要一个像这样的伪代码: git clone --ignore wp-content / uploads



是将该目录添加到的最佳方式。 gitignore,克隆,然后恢复.gitignore?还是有更好的方法?

解决方案

晚会有点迟,但是:您不想要一个稀疏的结帐吗?

  mkdir< repo> &安培;&安培; cd< repo> 
git init
git remote add -f< name> < URL>

启用稀疏结帐:



<$ p $通过列出你的配置来配置稀疏检出功能。

git config core.sparsecheckout true

所需的子树在.git / info / sparse-checkout中:

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

从远程结帐:

  git pull< remote> <分支> 

请参阅 http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/ 以获取更多信息。


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?

解决方案

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.

这篇关于git clone,忽略一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆