只是好奇 Git 是否有类似 Subversions Changelist 的功能,我发现它在运行中非常方便,我知道我可以运行类似的东西:
cat 'changelistfileimade' | xargs git update
但我很好奇是否也有内置方法?
最佳答案
为此我在谷歌上搜索了更多,我想我已经找到了 TortoiseSVN ignore-on-commit changelist 的替代品我在上面的评论中提到的用例。有问题的命令是 git update-index --assume-unchanged <path/name> . Git 帮助对此有如下说明:
--[no-]assume-unchanged
When these flags are specified, the object names recorded for the paths are not updated. Instead, these options set and unset the "assume unchanged" bit for the paths. When the "assume unchanged" bit is on, Git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell Git when you change the working tree file. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).
This option can be also used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what .gitignore does for untracked files). Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.
我在 Nick Quaranto's GitReady blog 上找到了选项的解释,其中包括以下内容:
Obviously there’s quite a few caveats that come into play with this. If you
git addthe file directly, it will be added to the index. Merging a commit with this flag on will cause the merge to fail gracefully so you can handle it manually.
但这对我来说只是成功的一半。下一步是了解您忽略了什么(并希望记住原因)。这是由 this handy comment 提供的由 Abe Voelker 在一个恰当命名的问题上发表。只需编辑您的 .gitconfig包含代码段的文件
[alias]
ignored = !git ls-files -v | grep "^[[:lower:]]"
不要添加 [alias] bit 如果它已经存在于你的文件中。现在git ignored会告诉你这样的事情:
h configs/environment/local.php
h configs/logging/log4php.xml
您可以使用别名更进一步 ignore和 unignore包含以下几行:
ignore = update-index --assume-unchanged
unignore = update-index --no-assume-unchanged
关于SVN Changelist 的 Git 等效项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10606809/
我的目标是转换表单输入,例如“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看起来疯狂不安全。所以,功能正常,
文章目录git常用命令(简介,详细参数往下看)Git提交代码步骤gitpullgitstatusgitaddgitcommitgitpushgit代码冲突合并问题方法一:放弃本地代码方法二:合并代码常用命令以及详细参数gitadd将文件添加到仓库:gitdiff比较文件异同gitlog查看历史记录gitreset代码回滚版本库相关操作远程仓库相关操作分支相关操作创建分支查看分支:gitbranch合并分支:gitmerge删除分支:gitbranch-ddev查看分支合并图:gitlog–graph–pretty=oneline–abbrev-commit撤消某次提交git用户名密码相关配置g
关于如何使用git设置类似Dropbox的服务,您有什么建议吗?您认为git是解决此问题的合适工具吗?我在考虑使用git+rush解决方案,你觉得怎么样? 最佳答案 检查这个开源项目:https://github.com/hbons/SparkleShare来自项目的自述文件:Howdoesitwork?SparkleSharecreatesaspecialfolderonyourcomputer.Youcanaddremotelyhostedfolders(or"projects")tothisfolder.Theseprojec
我编写了一个非常简单的“部署”脚本,作为我的裸git存储库中的post-updateHook运行。变量如下livedomain=~/mydomain.comstagingdomain=~/stage.mydomain.comgitrepolocation=~/git.mydomain.com/thisrepo.git(bare)core=~/git.mydomain.com/thisrepo.gitcore==addedremoteintoeachlive&stagegitslive和stage都初始化了gitrepos(非裸),我已经将我的裸仓库作为远程添加到它们中的每一个(名为co
我正在安装gitlabhq,并且在Gemfile中有对某些资源的“git://...”的引用。但是,我在公司防火墙后面,所以我必须使用http://。我可以手动编辑Gemfile,但我想知道是否有另一种方法告诉bundler使用http://作为git存储库? 最佳答案 您可以通过运行gitconfig--globalurl."https://".insteadOfgit://或通过将以下内容添加到~/.gitconfig:[url"https://"]insteadOf=git://
Activeadmingem已添加到我的rails项目中,但每次我尝试安装railsgactive_admin:install时,我都会收到类似的错误git://github.com/activeadmin/activeadmin.git(atmaster)isnotyetcheckedout.Runbundleinstallfirst.我肯定在运行“railsgactive_admin:install”之前运行了bundle。运行“bundleshow”后,我看到我已将“*activeadmin(1.0.0.pre3f916d6)”添加到我的项目中,但不断收到此错误消息。我的gem文
什么是Linq聚合方法的ruby等价物。它的工作原理是这样的varfactorial=new[]{1,2,3,4,5}.Aggregate((acc,i)=>acc*i);每次将数组序列中的值传递给lambda时,变量acc都会累积。 最佳答案 这在数学以及几乎所有编程语言中通常称为折叠。它是更普遍的变形概念的一个实例。Ruby从Smalltalk中继承了这个特性的名称,它被称为inject:into:(像aCollectioninject:aStartValueinto:aBlock一样使用。)所以,在Ruby中,它称为inj
这可能是一段很长的时间,但如果存在的话会让生活变得更轻松一些。无论如何,这都是场景。我有一个散列数组,其中一个键的值是另一个散列.......是的,我知道。这里有一个更好的解释:@myArrayOfStuff[0]@myArrayOfStuff[0]["single-key"]@myArrayOfStuff[0]["single-key"]["object-identifier"]第一个返回一个散列。第二个将返回一个对象(在我的例子中称为页面,但示例使用不同的名称)第三个返回我作为对象标识符引用的任何变量。足够简单。我想做的是选择另一个对象标识符值不为零或大于x的数组。类似于activ
我有一个运行良好的curl命令,但我需要在ruby脚本中自动执行它,curl命令:curl-uusrname:pwd-XPOST--data"del=false&val=100"http://localhost:1111/sample/path我写了下面的代码:uri=URI::HTTPS.build(:host=>"localhost",:port=>1111)uri.path=URI.escape("/sample/path")client=Net::HTTP.new("localhost","1111")req=Net::HTTP::Post.new(uri.request_
Hash#to_s(inspect的别名)始终以1.8哈希样式输出数据:{key:"value"}.to_s=>"{:key=>\"value\"}"是否有任何核心方法将其序列化为1.9哈希样式?{key:"value"}.to_s=>"{key:\"value\"}"我在已知数据上使用它进行代码重构;由于Ruby倾向于实现所有内容,我希望我只是找错了地方。当然,你可以用丑陋的方式破解它"{"+my_hash.to_a.map{|pair|pair[0].to_s+":"+pair[1].inspect}*",\n")+"}"但我希望有一个经过单元测试且完全正确的核心方法。