这是非常不直观的:
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 …
有什么办法可以临时覆盖 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/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) 我在 Windows 机器和我们的 git 存储库之一上运行 TeamCity (8.1) 时遇到问题。很少有文件(千分之二 - *.bytes 扩展名,二进制)在 TeamCity 签出上的大小比在开发人员计算机上的大。如果我关闭“将行结尾转换为 CRLF”,这些文件的大小是相同的,但项目的其余部分无法正确构建+开发人员机器确实有 core.autocrlf=true。
我还尝试将 *.bytes 设置为 .gitattributes 中的二进制文件,但这看起来像是被 TeamCity 忽略(?)。
有谁知道有什么方法可以让它发挥作用吗?
谢谢
我正在尝试在 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) 我正在尝试处理 .gitattributes 中没有扩展名的文件:
* text=auto
*. eol=lf
.py eol=lf
Run Code Online (Sandbox Code Playgroud)
*.显然没有帮助。git check-attr --all -- ./foo输出:
./foo: 文本: 自动
如何才能做到这一点?
我的存储库使用 git LFS 并在其 .gitattributes 中包含诸如此类的行:
*.jar filter=lfs diff=lfs merge=lfs -text
Run Code Online (Sandbox Code Playgroud)
我想直接在 repo 中存储一个 .jar 文件,不涉及 LFS。理想情况下,我会让 LFS 不适用于包含该 jar 的目录下的任何内容。有没有办法做到这一点?
我很确定我明白文件末尾没有换行符是什么意思。我想提供一个我很久以前创建并重新定位的分支的拉取请求(提交可能来自之前.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) 网上有很多文章说将二进制文件放在 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 ×10
gitattributes ×10
git-lfs ×2
ansible ×1
bash ×1
diff ×1
executable ×1
lf ×1
line-endings ×1
linux ×1
teamcity ×1
vim ×1
windows ×1