Git忽略gitconfig? [英] Git ignoring gitconfig?

查看:221
本文介绍了Git忽略gitconfig?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Git忽略〜/ .gitconfig

$ git config --global core.filemode false

$ git config -l
core.filemode=false
core.filemode=true

因此,现在有两个条目用于 core.filemode ,git仍然不会忽略文件模式更改

So now there are 2 entries for core.filemode and git is still not ignoring filemode changes

$ touch modetest

$ git add .

$ git commit -m test1
[master (root-commit) 320cfe4] test1
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 modetest

$ chmod +x modetest

$ git diff
diff --git a/modetest b/modetest
old mode 100644
new mode 100755

基于 torek's answer ,我将这一行添加到我的 .bash_profile

Based on torek’s answer, I added this line to my .bash_profile

[ -d .git ] && git config core.filemode false


推荐答案

也许有点矫枉过正,但是在Cygwin这让我困扰不已,足以深入挖掘这个问题。当从源代码构建git时,它会检查它所构建的文件系统是否理解可执行位。

Maybe a bit overkill, but in Cygwin this bothered me enough to dig into the issue more. When git is built from source code, it checks the file system it's built on to see if it understands executable bits.

我继续从Cygwin的源代码构建git系统并将其安装到本地目录,然后将二进制文件添加到我的路径中。基本步骤是:

I went ahead and built git from source on my Cygwin system and installed it to a local directory, then added the binary to my path. The basic steps are:

cd ~/
mkdir git
cd git
mkdir inst
git clone -c core.autocrlf=false https://github.com/git/git.git
cd git
NO_TRUSTABLE_FILEMODE=1 make prefix=/home/[username]/git/inst/
NO_TRUSTABLE_FILEMODE=1 make prefix=/home/[username]/git/inst/ install

然后在.bashrc中添加如下内容:

Then add something like this to .bashrc:

export PATH=/home/[username]/git/inst/bin:$PATH

当然,除非所有的构建依赖关系安装在Cygwin中。随着一点点刺激,我能够做到这一点,没有太多的麻烦。现在在该系统上的git init和git clone将filemode默认为false。诀窍是为构建定义NO_TRUSTABLE_FILEMODE。

Of course, that build won't work unless you have all the build dependencies installed in Cygwin. With a little poking around I was able to do it without too much trouble. Now git init and git clone on that system defaults filemode to false. The trick is defining NO_TRUSTABLE_FILEMODE for the build.

这篇关于Git忽略gitconfig?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆