Search code examples
gitfile-permissionsgitignore

remove execute only file from git tracking


I needed to make a file in a repository non-readable and non-writable:

sudo chmod 101 file1.sh

when you list it it looks like this:

$ ls -la file1.sh
---x-----x 1 cardamom cardamom 13 Nov 16 16:52 file1.sh

git add will not work:

error: open("file1.sh"): Permission denied
error: unable to index file file1.sh
fatal: updating files failed

and adding it to .gitignore does not cause it to be ignored.
I don't really need to track it, but would be good to not have it pop up every time git status is typed in.

How does one either add it to the repo or tell git to ignore it?


Solution

  • How does one either add it to the repo or tell git to ignore it?


    --assume-unchaged

    Raise the --assume-unchaged flag on this file so it will stop tracking changes on this file

    --[no-]assume-unchanged

    When this flag is specified, the object names recorded for the paths are not updated.

    Instead, this option sets/unsets the assume unchanged bit for the paths.

    When the assume unchanged bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

    Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.

    enter image description here