1

I have set the filemode setting to 'false' in git.

git config core.filemode false

And I made the file and committed it. All created file mode is 644.

I want to commit with 755 filemode, while filemode config is set to false.

Help me. Thank you

nj2237
  • 1,220
  • 3
  • 21
  • 25
이경언
  • 156
  • 1
  • 11
  • Are you on windows or linux? – Ferrybig Aug 07 '17 at 06:18
  • both. I was test in windows and linux. two OS same situation. – 이경언 Aug 07 '17 at 06:30
  • `core.fileMode` only tells Git whether to handle the executable bit or not. I do not believe you can tell to *not* handle the executable bit but still create tree objects with it set. – poke Aug 07 '17 at 06:59
  • Possible duplicate of [How to create file execute mode permissions in Git on Windows?](https://stackoverflow.com/questions/21691202/how-to-create-file-execute-mode-permissions-in-git-on-windows) (the answer should work for your situation) – Ferrybig Aug 07 '17 at 07:07
  • @poke I create files. one filemode is 222, the other filemode is 777. and commit. All file mode is set to 644. And the other people clone this git. all filemode is set to 644. – 이경언 Aug 07 '17 at 07:13
  • @Ferrybig thank you. I didn't know git update-index --chmod=+x . this is very good. But I want to always chmod +x all file. Can I?? ex) I create files. one filemode is 222, the other filemode is 777. and commit. I want to all file mode is set to 755. – 이경언 Aug 07 '17 at 07:24
  • That’s because Git only tracks whether the executable bit is set or not. And by disabling `core.fileMode` you are telling Git to not even do that. – poke Aug 07 '17 at 07:24
  • @poke thank you poke!!! Finally I know what you mean. I was set to filemode true. And i was create file set to filemode(111) and commit. Filemode is 755. And i was create file set to filemode(222) and commit. Filemode is 644. Thank you! – 이경언 Aug 07 '17 at 07:34

2 Answers2

4

Git does not track individual file modes. The only thing that Git does is track whether a file has the executable flag set or not. As such, Git will only ever store one of two possible file modes: 644 or 755, the latter meaning that the executable flag was set.

The core.fileMode setting will basically control this behavior. If you disable it by setting it to false, you are essentially telling Git to no longer check for the executable bit, so all files will be committed as not executable by default (so all of them are 644).

To quote the documentation on core.fileMode:

core.fileMode

Tells Git if the executable bit of files in the working tree is to be honored.

So disabling this will not help you here. However, I do not believe that it’s possible to tell Git to commit all files as executable by default. You will have to set the executable bit individually.

poke
  • 369,085
  • 72
  • 557
  • 602
0

Also see core.sharedRepository

the repository is made shareable between several users in a group (making sure all the files and objects are group-writable)

  • group (everyone in the linux group this file is owned by),
  • all (world, everyone),
  • umask (what the file says, default),
  • and a full 0xxx octal number as known from chmod.

This seem to represent linux access filemode very well.

luckydonald
  • 5,976
  • 4
  • 38
  • 58