首页 文章

如何在svn repo中本地忽略.git和.gitignore?

提问于
浏览
8

我有一个SVN工作副本(由TortoiseSVN管理) . 在该工作副本中,我使用git进行本地版本控制和分支 . 当然,我想为svn隐藏.git目录和.gitignore文件 .

但是,忽略它们意味着将属性添加到不再是本地的存储库 . 我不希望这(因为许多人共享这个回购)因为它很烦人,因为建议在每次提交回购时提交 .

我找到了(通过question)ignore-on-commit列表的可能性 . 但是(至少在TortoiseSVN中)它只适用于文件:如果我检查修改,则repo会显示修改后的属性 . 但是,由于上下文菜单条目没有显示,我无法将其添加到ignore-on-commit .

那么,是否有一种方法(f.ex. by commandline?)将repo添加到ignore-on-commit中?

还有其他方法可以隐藏/忽略svn的.git和.gitignore吗?

1 回答

  • 12

    使用 global-ignores 配置选项 . 这在SVN Book's Ignoring Unversioned Items section中有记载 .

    此设置将影响所有Subversion客户端和工作副本,但我怀疑忽略所有检出的.git和.gitignore对您来说不是问题 .

    Direct editing of the config file

    在Unix上,该设置将应用于 ~/.subversion/config ,在Windows上它将是 %APPDATA%\Subversion\config (尽管它也可以存储在注册表中,see the documentation in the SVN Book about that) .

    默认将被注释掉,如下所示:

    ### Set global-ignores to a set of whitespace-delimited globs
    ### which Subversion will ignore in its 'status' output, and
    ### while importing or adding files and directories.
    ### '*' matches leading dots, e.g. '*.rej' matches '.foo.rej'.
    # global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
    #   *.rej *~ #*# .#* .*.swp .DS_Store
    

    您只需取消注释行并将 .git.gitignore 添加到它们 .

    TortoiseSVN UI

    在您的情况下,您正在使用TortoiseSVN,因此您可以避免直接编辑文件并使用TortoiseSVN中的设置 . 在 General 部分下有一个 Subversion 块,其编辑块标记为 Global ignore pattern . 只需将 .git.gitignore 添加到模式列表中即可 . 这在Ignoring files and directories部分的Global ignores块中有所涉及,更具体地说,在TortoiseSVN文档的Settings sectionGlobal ignore pattern 设置的详细信息中有所介绍 .

相关问题