我希望git diff输出所有文件的常规差异,除了*.tex.对于*.tex文件,我想看看输出git diff --word-diff.
我和玩弄.gitattributes和.gitconfig,但我得到了最远的是得到一个.tex文件中的部分显示,随后坠毁.
有可能得到这种行为吗?
我的.gitattributes:
*.tex diff=latex
Run Code Online (Sandbox Code Playgroud)
.gitconfig:
[diff "latex"]
wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"
command = ~/bin/word-diff.sh
Run Code Online (Sandbox Code Playgroud)
并且word-diff.sh:
#!/bin/sh
git --no-pager diff --color-words "$2" "$5"
Run Code Online (Sandbox Code Playgroud) 我有一个.gitattributes清理过滤器,用于在提交之前删除文件中的所有注释.
$ cat .git/config
[filter "cleancomments"]
clean = "grep -v '^#'"
$ cat .gitattributes
* filter=cleancomments
Run Code Online (Sandbox Code Playgroud)
我有一个文件'test',其中包含以下内容(在存储库中提交):
This is a file with random content
Run Code Online (Sandbox Code Playgroud)
现在我对'test'进行修改并添加注释:
This is a file with random content
# and some comments
# like this
Run Code Online (Sandbox Code Playgroud)
git status 现在告诉我:
modified: test
Run Code Online (Sandbox Code Playgroud)
但是git diff是空的(应该如此).
我不完全清楚为什么git status不使用过滤器来决定文件是否被修改,但我认为这是它的实现方式.
对我来说真正神秘的是:
如果我这样做:
git add test
Run Code Online (Sandbox Code Playgroud)
然后突然文件'test'不再标记为已修改,并且它不会出现在git索引中.为什么是这样?
我有一个像这样的目录结构:
root/
.git
deploy/
Site/
blah/
more_blah/
something.local
else.development
Rakefile
.gitattributes
Run Code Online (Sandbox Code Playgroud)
编辑:为了进一步说明上面的内容,目录有一个尾随,子目录/在目录下缩进,所以blah并且more_blah是目录但是Rakefile和.gitattributes文件,但所有四个都是子目录Site.
我正在git-archive从这样的Site目录运行:
git archive --format=tar --prefix=git-v0.0.1/ v0.0.1 | gzip > ../deploy/git-v0.0.1.tar.zip
Run Code Online (Sandbox Code Playgroud)
但无论我放入.gitattributes的模式,生成的存档总是包含Rakefile.我试过了:
它们都没有像我期望的那样工作.是否有人愿意指出明显但不明显的解决方案?任何帮助深表感谢.
我很抱歉不清楚.
Rakefile 不是目录,只是一个文件Rakefile不是唯一使用的模式,但是唯一不起作用的模式.无论我是单独使用它还是使用其他模式,以及文件中的任何位置,它都不起作用.这是我.gitattributes(坐在目录中Site)
Rakefile export-ignore
*.local export-ignore
*.development export-ignore
*.staging export-ignore
Run Code Online (Sandbox Code Playgroud) 我有以下目录结构:
project/
.git/
...
app/
...
config/
initializers/
braintree.rb
environments/
production.rb
.gitattributes
Run Code Online (Sandbox Code Playgroud)
我的项目使用两个主要分支,主分支和分段,每个分支跟踪不同的远程(生产和暂存heroku应用程序).
我们的想法是,分段分支随着新功能向前移动,它们被推送到临时远程控制台并进行测试,然后快速转发主分区以匹配分段并推送到生产远程.
这就是我想要做的事情:自由合并这两个分支,同时保持它们的版本braintree.rb和production.rb分离.
为了实现这一点,这里是我提出的.gitattributes(根据ProGit书):
config/initializers/braintree.rb merge=ours
config/environments/production.rb merge=ours
Run Code Online (Sandbox Code Playgroud)
该文件存在于两个分支中.
我遇到的问题是,这似乎对任何事情没有任何影响.每当我在两者之间合并时,无论如何文件都会被更改,我必须再次更改它们.
我有一种感觉,我错过了一些非常明显的东西,但到目前为止它正在逃避我.我知道其他答案涉及创建自定义合并驱动程序,但ProGit书中没有提到这个过程,似乎暗示ours驱动程序是内置的(我已经在手册页中看到过它,所以我是相对确定它是).我能想到的另一件事就是我以某种方式放.gitattributes错了地方或弄乱了它的内容,但我找不到太多关于此的信息.我已经尝试将它移动到与文件相同的目录,但无济于事.
如果它有任何帮助,我在OS X上运行git版本1.7.2.任何帮助将不胜感激.
我有一个git存储库.gitattributes:
my_script.py export-subst
Makefile export-ignore
README.md export-ignore
.gitattributes export-ignore
.gitignore export-ignore
hooks/ export-ignore
tests/ export-ignore
*.pyc export-ignore
Run Code Online (Sandbox Code Playgroud)
但当我做:
git archive HEAD | tar -x -C ../archive_dir
Run Code Online (Sandbox Code Playgroud)
在archive_dir目录中,我得到目录hooks和tests:
ls ../archive_dir/
hooks/ my_script.py tests/
Run Code Online (Sandbox Code Playgroud)
为什么?
我的git版本是1.7.9.
我有一个存储库来存储我的所有Vim设置.它使用子模块来插入Pathogen的插件(我看过其他插件管理器,到目前为止没有兴趣).由于MSYSGit在为提交消息打开Vim时处理行结尾的方式,我需要将存储库与Unix行结尾一起存储(eol = lf).
我尝试在主仓库中添加一个带有内容的.gitattributes文件:
* eol=lf
* text=auto
Run Code Online (Sandbox Code Playgroud)
使用git rm --cached -r .和刷新主存储库后,主仓库中git reset --hard的行结尾现在是LF.但是,在子模块中运行相同的命令不起作用.
tl; dr:如何配置我的git repo以便用LF行结尾检出子模块?
我原本期望**/匹配 git 存储库中的任何目录,但实际上它什么也不匹配。man gitattributes说:
匹配目录的模式不会递归匹配该目录内的路径(因此在属性文件中使用尾部斜杠 path/ 语法是没有意义的;请改用 path/** )
但就我而言,甚至与目录本身**/不匹配。我的意思是,如果我的仓库中有,那么甚至不匹配 dir 。我期望它匹配 dir但不匹配 file 。a/b.txt**/aaa/b.txt
如果我更改**/为**,则目录及其内容都会匹配。在同一示例中,dira和 filea/b.txt都匹配。
那么 gitattributes 如何在目录上工作呢?如果 git 认为目录上的属性并不重要,那么为什么 git 在 的情况下列出它们**?
基于这篇文章: `.gitattributes`文件中`text = auto`的目的是什么?如果.gitattributes文件中包含以下内容,则 行结尾将转换为LF以用于文本文件:
* text=auto
Run Code Online (Sandbox Code Playgroud)
我刚刚在本地存储库上测试过:
$ git add -A
warning: LF will be replaced by CRLF in [bla]/.gitattributes.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in [bla]/.gitignore.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in [bla]/README.md.
The file will have its original line endings in your working directory.
warning: LF …Run Code Online (Sandbox Code Playgroud) 我已经阅读了.gitattributes 上的文档,并在 Stack Overflow 上搜索了这个问题的简单答案,但到目前为止还没有找到。我有一个文件,里面有空格,就像这样。
Reserved\ Slots.txt merge=mergeslots
Run Code Online (Sandbox Code Playgroud)
我还尝试使用引号而不是转义空格。
"Reserved Slots.txt" merge=mergeslots
Run Code Online (Sandbox Code Playgroud)
如何对包含空格的文件使用自定义合并驱动程序?
git ×10
gitattributes ×10
c# ×1
git-archive ×1
git-merge ×1
line-endings ×1
merge ×1
word-diff ×1