5

Background

I have a config file for SSH checked into a repository that is cloned by systems that run automated tests. I am running Linux (so are my target machines), and I accidentally checked the first version of the file in with a permissions field of 664. OpenSSH rejects the config file because of the group write permission.

I need to change the file permission bits to 644 and commit that change, but Git doesn't recognize the file as changed.

Question

How can I update the file write permissions in the repository?

Resolution Attempts

  • git add config --force
    The file is not added
  • git config core.filemode true
    File is still listed as unchanged
  • git rm --cached config
    git shows file as deleted, but reports no change the the file after "git add config"
  • changed the permission bits and added an extra line in the file, committed that change, and pushed it
    After pulling that change on another machine, the new blank line was present, but the new permissions were not propagated - they are still 664

Other Research

According to this thread, Git will only recognize changes in the execution bit. I tested changing the execution bit, and git does recognize that change and would allow me to commit it. But I don't want the execute permission bit set.

This SO question recommends using git-cache-meta to store permission bits besides the execution bit, but it looks like that solution requires modification of the remote server the repo is stored on, and I don't have control over that server.

I have consulted the following SO questions but they haven't helped:
How to force Git to commit a file if it is recognized as unchanged
Updating file permissions only in git

There are also multiple questions about getting Git to ignore permission bit changes, but the answers pretty much all revolve around the filemode config option, which doesn't help here.

Community
  • 1
  • 1
skrrgwasme
  • 9,358
  • 11
  • 54
  • 84

1 Answers1

0

The following question has the answer: Git is changing my file's permissions when I push to server

So how can you update the file write permissions in the repository? You can't because read/write permissions aren't actually stored in the repository.

My suggestion would be to add a script that changes permissions after cloning the repository or if you have actions blocked by the current permissions add some code that changes the permissions before doing the actions.

Ixio
  • 517
  • 6
  • 21