标签: gitattributes

在 Windows 中覆盖 .gitattributes text=auto

这是非常不直观的:

C:\python-tdl\examples\termbox>git config core.autocrlf
false

C:\python-tdl\examples\termbox>git commit termbox.py
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
Aborting commit due to empty commit message.
Run Code Online (Sandbox Code Playgroud)

根据各种媒体,core.autocrlf=false …

windows git gitattributes core.autocrlf

6
推荐指数
2
解决办法
4702
查看次数

从命令行覆盖 .gitattributes

有什么办法可以临时覆盖 git 中的属性,类似于如何-c使用覆盖配置选项?

我想git diff使用与textconv我通常使用的命令不同的特定自定义命令进行调用。

更具体一点:我的实际用例是使用jupytext.vim插件在 vim 中编辑 Jupyter 笔记本。

我的正常~/.gitconfig包含

[diff "jupyternotebook"]
    command = git-nbdiffdriver diff
Run Code Online (Sandbox Code Playgroud)

设置nbdime为差异驱动程序,然后在~/.gitattributes

*.ipynb diff=jupyternotebook
Run Code Online (Sandbox Code Playgroud)

现在我想要

[diff "jupytext"]
    textconv = jupytext --from=ipynb --to=md -o - <
Run Code Online (Sandbox Code Playgroud)

(或类似的东西)在 git 配置中,并表现git diff得好像

*.ipynb diff=jupytext
Run Code Online (Sandbox Code Playgroud)

在 .gitattributes 中。

我愿意将该[diff "jupytext"]部分永久添加到我的~/.gitconfig. 但是,根据传递给git diff.

或者,我可以使用命令行选项来git diff强制它使用~/.gitattributes优先于所有其他.gitattributes文件(例如,在同一目录中)的不同文件。

最终,在命令行选项旨在进入g:gitgutter_diff_args的设置vim-gitgutter。我想强制插件以不同的方式转换 …

git vim diff gitattributes

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

“openssl”] 不是有效的属性名称:.git/info/attributes:5

.git/info/attributes文件中设置属性时出现以下错误。

$ git add --dry-run . 
"openssl"] is not a valid attribute name: .git/info/attributes:5
"openssl"] is not a valid attribute name: .git/info/attributes:8
add '.gitignore'
add 'README.md'
Run Code Online (Sandbox Code Playgroud)

文件内容:

* filter=openssl diff=openssl

[merge]
        renormalize=true
[filter "openssl"]
        smudge=~/.gitencrypt/smudge_filter_openssl
        clean=~/.gitencrypt/clear_filter_openssl
[diff   "openssl"]
        textconv=~/.gitencrpt/diff_filter_openssl
Run Code Online (Sandbox Code Playgroud)

更新:

$ git version
git version 1.8.3.2
Run Code Online (Sandbox Code Playgroud)

git gitattributes

5
推荐指数
1
解决办法
2659
查看次数

TeamCity 的 git checkout 与本地 git checkout 不同

我在 Windows 机器和我们的 git 存储库之一上运行 TeamCity (8.1) 时遇到问题。很少有文件(千分之二 - *.bytes 扩展名,二进制)在 TeamCity 签出上的大小比在开发人员计算机上的大。如果我关闭“将行结尾转换为 CRLF”,这些文件的大小是相同的,但项目的其余部分无法正确构建+开发人员机器确实有 core.autocrlf=true。

我还尝试将 *.bytes 设置为 .gitattributes 中的二进制文件,但这看起来像是被 TeamCity 忽略(?)。

有谁知道有什么方法可以让它发挥作用吗?

谢谢

git teamcity gitattributes

5
推荐指数
0
解决办法
1844
查看次数

用于 ansible Vault 机密的 Git 清洁/涂抹过滤器

我正在尝试在 git 中设置清理/涂抹过滤器,以便通过ansible-vault命令自动加密和解密包含机密的文件。

ansible-vault 命令的特殊性在于它不是幂等的(每次在相同数据上调用它时都会创建不同的二进制文件)。

我从这个博客页面中建议的实现开始。不幸的是,它没有正常工作,因为每当调用 smudge 时(无论是 git checkout 还是 git status),秘密文件看起来都像 git 修改过的一样,即使不是。

所以我想知道 git 是否会将索引中的二进制文件与干净过滤的当前文件进行比较,我尝试在这些脚本上构建如下:

#!/bin/sh -x
# clean filter, it is invoked with %f

if [ ! -r "$HOME/.vault_password" ]; then
  exit 1
fi

tmp=`mktemp`
cat > $tmp

# get the plain text from the binary in the index
tmphead=`mktemp`
git show HEAD:$1 > $tmphead
contenthead=`echo "embedded" | ansible-vault view $tmphead --vault-password-file=$HOME/.vault_password`
export PAGER=cat
echo -n "$contenthead" | tee $tmphead …
Run Code Online (Sandbox Code Playgroud)

git gitattributes ansible ansible-vault

5
推荐指数
0
解决办法
435
查看次数

Git:使用可执行文件

我有一个项目,其中有一个.sh文件,一旦被其他人拉取,它就必须处于可执行模式。现在,我已经在本地计算机上更改了其权限。不过,我希望它也作为可执行文件推送/拉取,以便其他用户不必chmod一直运行命令。

我已被告知两种可能的解决方案:.gitattributesgit update-index --chmod=+x script.sh,但是考虑到我的情况,我不确定我到底应该遵循什么。

我在这里看到了这篇文章,在那里看到了这个答案,我在想哪一个更适合我的情况。我希望这个过程自动完成,而不是每次都由用户添加。

有什么想法吗?

linux git bash executable gitattributes

5
推荐指数
1
解决办法
4171
查看次数

.gitattributes 中没有扩展名的文件

我正在尝试处理 .gitattributes 中没有扩展名的文件:

* text=auto
*. eol=lf
.py eol=lf
Run Code Online (Sandbox Code Playgroud)

*.显然没有帮助。git check-attr --all -- ./foo输出:

./foo: 文本: 自动

如何才能做到这一点?

git gitattributes

5
推荐指数
1
解决办法
2215
查看次数

如何使 git LFS 不适用于子目录

我的存储库使用 git LFS 并在其 .gitattributes 中包含诸如此类的行:

*.jar filter=lfs diff=lfs merge=lfs -text
Run Code Online (Sandbox Code Playgroud)

我想直接在 repo 中存储一个 .jar 文件,不涉及 LFS。理想情况下,我会让 LFS 不适用于包含该 jar 的目录下的任何内容。有没有办法做到这一点?

git gitattributes git-lfs

5
推荐指数
1
解决办法
1537
查看次数

在 git diff 中避免“文件末尾没有换行符”

我很确定我明白文件末尾没有换行符是什么意思。我想提供一个我很久以前创建并重新定位的分支的拉取请求(提交可能来自之前.gitattributes添加的时间)。我看到一些.java源代码文件只有更改

-}
\ No newline at end of file
+}
Run Code Online (Sandbox Code Playgroud)

无论配置如何,我都希望将这些更改从 PR 提交中排除。我想避免选择更改git difftool并扩大我对git.

问题是,我已经不明白这种变化是如何存在的,因为有一个.gitattributes

# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text
*.java text
*.css text
*.js text
*.xml text
*.dtd text
*.xsl text
*.properties text
*.txt …
Run Code Online (Sandbox Code Playgroud)

git lf line-endings gitattributes

5
推荐指数
1
解决办法
8982
查看次数

我应该总是排除 git LFS 文件的文本属性吗?

网上有很多文章说将二进制文件放在 LFS 下是一个很好的做法。因此,.gitattributes文件将如下所示:

## Fonts
*.otf filter=lfs diff=lfs merge=lfs -text
*.OTF filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.TTF filter=lfs diff=lfs merge=lfs -text
Run Code Online (Sandbox Code Playgroud)

请注意,所有条目都包含-textwhich 告诉 git 不要将这些文件视为文本文件,而是将它们视为二进制文件。

现在,假设我想跟踪一些扩展*.yaml名为 LFS 的文本文件,因为它们非常大但仍然基于文本。我应该以与二进制条目相同的方式创建条目还是应该-text像这样省略?

*.yaml filter=lfs diff=lfs merge=lfs
*.YAML filter=lfs diff=lfs merge=lfs
Run Code Online (Sandbox Code Playgroud)

git gitattributes git-lfs

5
推荐指数
2
解决办法
864
查看次数