我有一个项目,在开发时,我必须将chmod文件的模式更改为777,但在主库中不应更改。

Git拿起了chmod-R777。并将所有文件标记为已更改。有没有办法让Git忽略对文件所做的模式更改?


当前回答

这对我有用:

find . -type f -exec chmod a-x {} \;

或相反,取决于您的操作系统

find . -type f -exec chmod a+x {} \;

其他回答

If

git config --global core.filemode false

不适用于您,请手动执行:

cd into yourLovelyProject folder

cd到.git文件夹:

cd .git

编辑配置文件:

nano config

将true更改为false

[core]
        repositoryformatversion = 0
        filemode = true

->

[core]
        repositoryformatversion = 0
        filemode = false

保存,退出,转到上层文件夹:

cd ..

勒紧吉特

git init

你完蛋了!

如果要在配置文件中递归地(包括子模块)将filemode设置为false:find-name config | xargs sed-i-e's/filemode=true/filemode=false/'

这对我有用:

find . -type f -exec chmod a-x {} \;

或相反,取决于您的操作系统

find . -type f -exec chmod a+x {} \;

如果要为所有回购设置此选项,请使用--global选项。

git config --global core.filemode false

如果这不起作用,您可能使用的是更新版本的git,所以请尝试--add选项。

git config --add --global core.filemode false

如果在没有--global选项的情况下运行它,并且工作目录不是repo

error: could not lock config file .git/config: No such file or directory

撤消工作树中的模式更改:

git diff --summary | grep --color 'mode change 100755 => 100644' | cut -d' ' -f7- | xargs -d'\n' chmod +x
git diff --summary | grep --color 'mode change 100644 => 100755' | cut -d' ' -f7- | xargs -d'\n' chmod -x

或以明吉计

git diff --summary | grep  'mode change 100755 => 100644' | cut -d' ' -f7- | xargs -e'\n' chmod +x
git diff --summary | grep  'mode change 100644 => 100755' | cut -d' ' -f7- | xargs -e'\n' chmod -x

或在BSD/macOS中

git diff --summary | grep --color 'mode change 100644 => 100755' | cut -d' ' -f7- | tr '\n' '\0' | xargs -0 chmod -x
git diff --summary | grep --color 'mode change 100755 => 100644' | cut -d' ' -f7- | tr '\n' '\0' | xargs -0 chmod -x