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

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


当前回答

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

你完蛋了!

其他回答

这可能有效:git-config-core.fileMode false

这对我有用:

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

你完蛋了!

如果设置:sudo chmod 777-R

可以运行:git-config-core.fileMode false

你可以:https://www.w3docs.com/snippets/git/how-to-make-git-ignore-file-mode-changes.html

如果您已经使用了chmod命令,请检查文件的差异,它显示以前的文件模式和当前的文件模式,例如:

新模式:755

旧模式:644

使用以下命令设置所有文件的旧模式

sudo chmod 644。

现在使用命令或手动在配置文件中将core.fileMode设置为false。

git config core.fileMode false

然后应用chmod命令更改所有文件的权限,例如

sudo chmod 755 .

并再次将core.fileMode设置为true。

git config core.fileMode true

对于最佳实践,不要始终保持core.fileMode为false。