标签: gitattributes

这个git涂抹/清洁过滤器有什么问题?

我想在我的git存储库中应用此过滤器,以在结帐时从解决方案文件中删除一个部分,并在提交期间添加此部分.

这是我要删除或添加的部分:

GlobalSection(SubversionScc) = preSolution
    Svn-Managed = True
    Manager = AnkhSVN - Subversion Support for Visual Studio
EndGlobalSection
Run Code Online (Sandbox Code Playgroud)

我在.git/info/attributes中设置了这个过滤器

*.sln filter = SourceControlProvider

我已将这些命令添加到我的配置中

$ git config filter.SourceControlProvider.smudge "sed -e '/GlobalSection(SubversionScc)/,/EndGlobalSection/d' %"
$ git config filter.SourceControlProvider.clean "sed -n -e '/^Global$/ r ankhsvnsection ' < %"
Run Code Online (Sandbox Code Playgroud)

好吧,它不起作用.我做错了什么?

ankhsvnsection是一个文本文件,与*.sln文件位于同一目录中

git sed filter gitattributes

7
推荐指数
1
解决办法
5815
查看次数

git line endings:renormalize似乎没有检查右边的结尾

我决定通过.gitattributes文件详细设置我的行结束正确的方式- 例如这里 - 所以我将core.autocrlf设置为false并创建并提交了一个.gitattributes文件:

*.java text eol=native
*.jsp text eol=native
*.css text eol=native
*.html text eol=native
*.js text eol=native
*.xml text eol=native
*.sql text eol=native
*.MF text eol=native

# git files
*.gitignore text eol=native
*.gitattributes text eol=native

#eclipse files
*.classpath text eol=native
*.project text eol=native
*.prefs text eol=native
*.properties text eol=native
Run Code Online (Sandbox Code Playgroud)

然后我按照这里的建议发布git rm --cached -r .然后git reset --hard(也尝试过git checkout HEAD).现在所有文件都有LF行结尾.不应该是CRLF?我错过了什么?我在Windows 7上.git version 1.8.0.msysgit.0

谢谢

git line-endings gitattributes

7
推荐指数
1
解决办法
2751
查看次数

.gitattributes模式中的空格

我正在为git编写一些使用涂抹/清除过滤器的工具,因此我必须在.gitattributes文件中创建条目.

不幸的是,通过在空白上拆分来解析该文件非常简单,因此我似乎不可能在模式中包含显式空格字符.

我一直在用空格字符替换?,再次匹配零个或一个字符.

Ergo,一种模式has?spaces将匹配我的目标文件名has spaces,但也hasspaces.

有没有办法只匹配空格,还是我坚持近距离比赛?

git gitattributes

7
推荐指数
1
解决办法
1550
查看次数

根据文件类型选择git mergetool

在运行时git mergetool,我想让git选择基于文件扩展名使用的合并工具.我怎样才能做到这一点?

这里也提出了类似的问题:Git:为difftool和mergetool配置模式, 答案是编写自定义合并驱动程序.但是,似乎这将被执行git merge,而我希望选择合并工具git mergetool.

似乎必须有一些方法来指定.gitattributes,但我似乎无法弄清楚如何.有什么建议?

git merge git-config gitattributes

7
推荐指数
1
解决办法
3188
查看次数

列出所有具有git属性集的文件

git check-attr允许我检查是否.gitattributes为特定文件集设置了属性.例如:

# git check-attr myAttr -- org/example/file1 org/example/file2
org/example/file1: myAttr: set
org/example/file2: myAttr: unspecified
Run Code Online (Sandbox Code Playgroud)

是否有一种简单的方法可以列出所有已myAttr设置的文件,包括所有通配符匹配?

git gitattributes

7
推荐指数
2
解决办法
1969
查看次数

通过.gitattributes强制执行core.autocrlf = input

有没有办法core.autocrlf=input从内部强制执行.gitattributes以便在整个同事中传播策略?

在细节我要的是转换为lf添加并保留as is结帐.

问题在于既没有texteol没有我想要的东西,.gitattributes因为它eol有3个可接受的值:

  1. lf
  2. crlf
  3. native

理想情况下,我希望我的.gitattributes文件看起来像这样:

* text eol=asis

git line-endings eol gitattributes core.autocrlf

7
推荐指数
2
解决办法
2546
查看次数

挂钩或不挂钩 - git

我们的定制IDE输出XML文件,其编码使它们看起来像二进制文件.这些文件的差异和合并失败.

我们可以使用该tr命令创建这些文件的ASCII版本.我想进入一个状态,在这些文件提交之前总是自动转换为ascii.

用Git拿起了我的版本控制副本,它全心全意警告我不要使用钩子,除非我真的需要.

我应该为此目的使用钩子吗?或者我可以做其他事情以确保文件在提交之前始终被转换?

Windows XP与msysgit 1.7.4

- = update = -

感谢大家的帮助和耐心.期待这个问题我尝试了以下,但它不起作用:

echo "*.xrp    filter=xrp" > .git/info/attributes
git config --global filter.xrp.clean 'tr -cd '\''\11\12\15\40-\176'\'''
git config --global filter.xrp.smudge cat
git checkout --force
Run Code Online (Sandbox Code Playgroud)

此配置更改后,文件保持不变.即使我删除并重新结账.

tr配置为clean任务的命令确实可以单独工作.证明:

$ head -n 1 cashflow/repo/C_GMM_CashflowRepo.xrp
ÿþ< ! - -   X M L   R e p o s i t o r y   f i l e   1 . 0   - - >

$ tr …
Run Code Online (Sandbox Code Playgroud)

git hook tr gitattributes

6
推荐指数
1
解决办法
1203
查看次数

在 git 中为相同的文件应用多个过滤器

我正在使用 Git 对本地文件进行版本控制,最终必须将其签入另一个版本控制系统。现在我遇到了大多数 C 代码文件的一些问题:

  1. 它们的标题注释中都有自动版本历史记录
  2. 大多数文件都被 EasyCode 或 EasyCase 注释弄得乱七八糟

我现在简单地创建了两个 git 过滤器“History”和“EasyTool”来清理代码,然后再签入 Git。如何使用这两个过滤器过滤所有 C 和 H 文件?

多次指定命令不起作用,过滤命令的串联也不起作用(或者我至少没有找到正确的语法)。

这是我的第一次尝试:

*.c  filter=History
*.c  filter=EasyTool           # This one wins, "History" is not executed
Run Code Online (Sandbox Code Playgroud)

然后我尝试了这样的事情:

*.c  filter=History EasyTool   # The first wins, other separators work neither
Run Code Online (Sandbox Code Playgroud)

git version-control filter gitattributes

6
推荐指数
1
解决办法
1202
查看次数

如何列出 git 存储库中跟踪文件的所有不同扩展名?

我想知道git 在给定存储库中跟踪的文件的所有不同扩展名,以便创建适当的.gitattributes文件。

预期输出示例:

bat
gitignore
gradle
html
jar
java
js
json
md
png
properties
py
svg
webp
xml
yml
Run Code Online (Sandbox Code Playgroud)

我可以使用什么命令来实现这一点?

git bash grep gitattributes

6
推荐指数
1
解决办法
2323
查看次数

为什么 GitHub 会忽略将某些文件标记为二进制的 .gitattributes 模式?

我想从 GitHub 上的行计数统计中排除一些文件,例如 *.dat 文件。

在 .gitattributes 中应该可以这样做:

*.dat text -diff

或者

*.dat binary

如果我在使用上述设置提交 .gitattributes 后提交 .dat 文件,GitHub Desktop(适用于 Windows)会正确显示“此二进制文件已更改”,并且不会显示任何差异,并且不会将其计入用户贡献中。然而,在 GitHub.com 上,同一文件仍被视为标准源代码文件,并且所有添加和删除都会被计数。

您可以在这个小型测试存储库中看到它: https://github.com/btitze/line-count-test

这是 GitHub.com 上的错误吗?我希望以与 *.png 文件相同的方式处理 *.dat 文件,这些文件的行数永远不会被计算在内。

git github gitattributes

6
推荐指数
0
解决办法
245
查看次数