web-dev-qa-db-ja.com

Gitはフォルダーのアクセス許可をどのように処理しますか?

私はgitバージョン1.5.6.3を使用していますが、gitはフォルダのモード変更に気付かないようです

#create a test repository with a folder with 777 mode
:~$ mkdir -p test/folder
:~$ touch test/folder/dummy.txt
:~$ cd test
:~/test$ chmod 777 folder/

#init git repository
:~/test$ git init
Initialized empty Git repository in ~/test/.git/
:~/test$ git add .
:~/test$ git commit -m 'commit a directory'
Created initial commit 9b6b21a: commit a directory
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 folder/dummy.txt

#change folder permission to 744
:~/test$ chmod 744 folder/
:~/test$ git status 
# On branch master
nothing to commit (working directory clean)

04000の略?

:~/test$ git ls-tree HEAD folder
040000 tree 726c1d5f0155771348ea2daee6239791f1cd7731    folder

これは正常な動作ですか?

フォルダーモードの変更を追跡するにはどうすればよいですか?

45
hdorio

gitが追跡する唯一の「許可」ビットは、ファイルの実行可能ビットです。残りのモードビットは、各gitツリーのオブジェクトがどのタイプのファイルシステムオブジェクトであるかを示します。 gitは、ファイルとシンボリックリンク(ブロブ)、ディレクトリ(ツリー)、およびサブモジュール(コミット)をサポートします。

gitは、異なるマシン間でソースコードを追跡できるように設計されています。許可ビットは、マシン間のユーザーとグループのマッピングに依存します。これらのマッピングが存在しない分散環境では、許可ビットの追跡は通常、何も助けずに物事を妨げることになります。

gitがネイティブに追跡できるファイルシステム属性をさらに追跡する必要がある場合は、 etckeeper などの拡張ツールを検討してください。

70
CB Bailey