How do I make git accept mode changes without accepting all text changes?

混江龙づ霸主 提交于 2019-11-30 01:24:10

git add -i will let you selectively add some hunks from a file to the index. I don't know whether or not it's sensitive to permissions, but if you were to add a hunk after the chmod operation, it might end up in the index correctly even without explicitly updating the permission.

You should be able to do:

git update-index --chmod=(+|-)x <file>

to adjust the executable bit stored in the index.

You can then commit this separately from any changes to the files content.

Steven Penny

Charles’ answer was adding both file mode and content changes to the index for me. I worked around it like this.

git update-index --skip-worktree --chmod=+x <file>
git update-index --no-skip-worktree <file>

Example

Alternatively you can do

git update-index --chmod=+x <file>
git config interactive.singlekey 1
echo na | git reset -p
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!