将GIT仓库中的文件标记为临时忽略 [英] Mark a file in the GIT repo as temporarily ignored
问题描述
使用P4,我可以将这些文件放入一个单独的更改列表中,然后忘记它们。同步不会覆盖它们,当我提交我的默认更改列表时,它们不会被提交。
有没有办法对GIT做类似的事情?
我想仍然能够git commit -a
.project
, .classpath
,...) ,您可以: - 这些文件的版本模板版本(
.project_tpl
,.classpath_tpl
,...) - 使用过滤驱动程序在结帐时生成实际文件(不会进行版本控制,只能在本地修改
(提交过程中的'
clean
'步骤不会执行任何为这些模板。
只有'smudge
'步骤在这里用于生成私人文件)
注意:这是过滤器驱动程序的轻微误用,wh ich应该只处理文件内容,而不是生成新文件。
但它可以帮助你在你的场景中(提供你的'smudge
'脚本不会盲目地覆盖eclipse文件,如果它们碰巧已经在这里了。)We're migrating from Perforce to GIT. In perforce, there were some files that I'd want in the repository, but they shouldn't be checked in by individual developers regularly. Things like eclipse project files. Each dev might get the initial .project file, but then tweak it slightly for their environment.
With P4, I could take those files, put them in a separate changelist and forget about them. Syncing wouldn't overwrite them and they wouldn't get committed when I commited my default changelist.
Is there a way to do something similar with GIT?
I'd like to still be able to "git commit -a"
解决方案If you need a common base for those (
.project
,.classpath
, ...), you can:- version template version of those files (
.project_tpl
,.classpath_tpl
, ...) - use a filter driver to generate, on checkout, the actual files (which won't be versioned, and only modified locally by the developers)
(the '
clean
' step during commit wouldn't do anything for those templates.
Only the 'smudge
' step is used here, to generate the private files)Note: this is a slight "mis-use" of a filter driver, which is supposed to process only file contents, not to generate new ones.
But it could help you in your scenario (provided your 'smudge
' script doesn't overwrite blindly the eclipse files if they happen to already be here.)这篇关于将GIT仓库中的文件标记为临时忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- version template version of those files (