table of Contents
Method 1: Use shell to modify permissions
Method 2: Use Git commands to modify permissions
scenes to be used
Sometimes it involves submitting file permissions changes to the repository. For example, the shell file we created has no execution permission by default. If the user pulls the code in the warehouse, you need to manually add execution permission to all shell files in the package before executing the code. Of course, we can also directly submit the modification of file permissions to the repository to avoid clumsy manual modification of file permissions.
Method 1: Use shell to modify permissions
Use the chmod command to modify the permissions of the file and submit it to the repository.
$ ll
total 16
drwxr-xr-x 7 liushuochen staff 224 1 10 11:15 ./
drwxr-xr-x+ 125 liushuochen staff 4000 1 10 11:33 ../
drwxr-xr-x 12 liushuochen staff 384 1 10 11:15 .git/
drwxr-xr-x 3 liushuochen staff 96 12 6 20:15 conf/
-rw-r--r-- 1 liushuochen staff 0 11 15 15:08 readme.md
-rw-r--r-- 1 liushuochen staff 19 1 9 22:39 tool.sh
-rw-r--r-- 1 liushuochen staff 34 1 10 11:15 tool2.sh
$ chmod 777 tool.sh
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: tool.sh
no changes added to commit (use "git add" and/or "git commit -a")
$ git add tool.sh
$ git commit -m "modify tool.sh"
[master c028e04] modify tool.sh
1 file changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 tool.sh
Method 2: Use Git commands to modify permissions
On Windows, Git commands are used to add or revoke execution permissions to files. Use git update-index --chmod=+x <file> to increase the execution authority of the file, and use git update-index --chmod=-x <file> to revoke the execution authority of the file.
git update-index --chmod=+x tool2.sh
git commit -am "revise permission access"
[master e5b2b16] revise permission access
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100755 tool2.sh