我开始接触 Git 并遇到以下问题:
我的项目源码树:
/
|
+--src/
+----refs/
+----...
|
+--vendor/
+----...
我的供应商分支中有代码(当前为 MEF),我将在那里编译,然后将引用移动到 /src/refs 中,这是项目从中获取它们的地方。
我的问题是我将 .gitignore 设置为忽略 *.dll 和 *.pdb。我可以执行 git add -f bar.dll 来强制添加被忽略的文件,这没问题,问题是我不知道要列出哪些文件存在被忽略。
我想列出忽略的文件以确保我不会忘记添加它们。
我已经阅读了 git ls-files 的手册页,但无法使其正常工作。在我看来 git ls-files --exclude-standard -i 应该做我想做的事。我错过了什么?
最佳答案
注意事项:
git status --ignored.gitignore files?”)git clean -ndX 适用于较旧的 git,显示可以删除哪些忽略文件的预览(不删除任何内容) 也很有趣(在 qwertymk 的 answer 中提到),你也可以使用 git check-ignore -v命令,至少在 Unix 上(在 CMD Windows session 中不起作用)
git check-ignore *
git check-ignore -v *
第二个显示 .gitignore 的实际规则,它使一个文件在你的 git 仓库中被忽略。
在 Unix 上,使用“What expands to all files in current directory recursively?”和 bash4+:
git check-ignore **/*
(或 find -exec 命令)
备注:https://stackoverflow.com/users/351947/Rafi B.建议 in the comments 避免(有风险的)globstar:
git check-ignore -v $(find . -type f -print)
确保从 .git/ 子文件夹中排除文件。
CervEd建议 the comments , 避免 .git/:
find . -not -path './.git/*' | git check-ignore --stdin
原答案42009)
git ls-files -i
应该可以,除了its source code表示:
if (show_ignored && !exc_given) {
fprintf(stderr, "%s: --ignored needs some exclude pattern\n",
argv[0]);
exc_given ?
事实证明,在 -i 之后还需要一个参数才能真正列出任何内容:
尝试:
git ls-files -i --exclude-from=[Path_To_Your_Global].gitignore
(但这只会列出您的缓存(未忽略的)对象,带有过滤器,所以这不是您想要的)
例子:
$ cat .git/ignore
# ignore objects and archives, anywhere in the tree.
*.[oa]
$ cat Documentation/.gitignore
# ignore generated html files,
*.html
# except foo.html which is maintained by hand
!foo.html
$ git ls-files --ignored \
--exclude='Documentation/*.[0-9]' \
--exclude-from=.git/ignore \
--exclude-per-directory=.gitignore
实际上,在我的“gitignore”文件(称为“exclude”)中,我找到了一个可以帮助你的命令行:
F:\prog\git\test\.git\info>type exclude
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
所以....
git ls-files --ignored --exclude-from=.git/info/exclude
git ls-files -i --exclude-from=.git/info/exclude
git ls-files --others --ignored --exclude-standard
git ls-files -o -i --exclude-standard
应该可以解决问题。
(感谢 honzajde 指出 in the comments git ls-files -o -i --exclude-from... 不包含缓存文件: 只有 git ls-files -i --exclude-from... (没有 -o)。)
如 ls-files man page 中所述, --others 是重要部分,目的是向您展示非缓存、非提交、通常被忽略的文件。
--exclude_standard 不仅仅是一个快捷方式,还是一种包含所有标准“忽略的模式”设置的方法。
exclude-standard
Add the standard git exclusions:.git/info/exclude,.gitignorein each directory, and theuser's global exclusion file.
关于显示 .gitignore 忽略了哪些特定文件的 Git 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/466764/
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
我试图在一个项目中使用rake,如果我把所有东西都放到Rakefile中,它会很大并且很难读取/找到东西,所以我试着将每个命名空间放在lib/rake中它自己的文件中,我添加了这个到我的rake文件的顶部:Dir['#{File.dirname(__FILE__)}/lib/rake/*.rake'].map{|f|requiref}它加载文件没问题,但没有任务。我现在只有一个.rake文件作为测试,名为“servers.rake”,它看起来像这样:namespace:serverdotask:testdoputs"test"endend所以当我运行rakeserver:testid时
我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,
Rails2.3可以选择随时使用RouteSet#add_configuration_file添加更多路由。是否可以在Rails3项目中做同样的事情? 最佳答案 在config/application.rb中:config.paths.config.routes在Rails3.2(也可能是Rails3.1)中,使用:config.paths["config/routes"] 关于ruby-on-rails-Rails3中的多个路由文件,我们在StackOverflow上找到一个类似的问题
对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta
我想用ruby编写一个小的命令行实用程序并将其作为gem分发。我知道安装后,Guard、Sass和Thor等某些gem可以从命令行自行运行。为了让gem像二进制文件一样可用,我需要在我的gemspec中指定什么。 最佳答案 Gem::Specification.newdo|s|...s.executable='name_of_executable'...endhttp://docs.rubygems.org/read/chapter/20 关于ruby-在Ruby中编写命令行实用程序