98
73

More than 5 years have passed since last update.

Gitでファイルの実行権限を変更する

Posted at

WindowsとLinuxをまたがって、スクリプトファイルを編集する場合のTips。

Linux系の場合、ファイルシステム上でファイル実行権限を変更する(chmod)と、Gitが「ファイルが変更された」と認識する。
そのため通常の変更と同じく、git addgit commitでファイルアクセス権をリポジトリに反映できる。

Windowsでアクセス権を変更したい場合は、下記のようなGitコマンドを使う。

実行権限を付与するとき
$ git update-index --add --chmod=+x [filename]

実行権限を外すとき
$ git update-index --add --chmod=-x [filename]

なお、config設定で「ファイル権限設定を無視する」というオプションがあるため、注意。
$ git config -l |grep filemode

98
73
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
98
73