git中sh文件添加可执行权限

66 篇文章 1 订阅
21 篇文章 0 订阅

参考:git中sh文件添加可执行权限

背景

有时我们需要在git仓库中放一些可执行脚本,但是部署到线上后却没有可执行权限,还要单独加权限,过程比较繁琐,下面介绍下如果修改git仓库中文件的权限

1.查看文件权限信息

$ git ls-files --stage

100644 b0a1909819160a88cf723cba9b082a41638e19d7 0       work.sh

发现644(r=4,w=2,x=1),需要将其修改为可执行权限755

git-ls-files - 显示有关索引和工作树中文件的信息

git update-index --help

语法规则

git ls-files [-z] [-t] [-v] [-f]

(--[cached|deleted|others|ignored|stage|unmerged|killed|modified])*

(-[c|d|o|i|s|u|k|m])*

[--eol]

[-x <pattern>|--exclude=<pattern>]

[-X <file>|--exclude-from=<file>]

[--exclude-per-directory=<file>]

[--exclude-standard]

[--error-unmatch] [--with-tree=<tree-ish>]

[--full-name] [--recurse-submodules]

[--abbrev] [--] [<file>…]

输出格式 [<tag> ]<mode> <object> <stage> <file>

$ git ls-files --stage

100644 b0a1909819160a88cf723cba9b082a41638e19d7 0       work.sh

2.增加可执行权限

git update-index --chmod +x work.sh

查看帮助

git update-index --help

语法规则

git update-index

     [--add] [--remove | --force-remove] [--replace]

     [--refresh] [-q] [--unmerged] [--ignore-missing]

     [(--cacheinfo <mode>,<object>,<file>)…]

     [--chmod=(+|-)x]

     [--[no-]assume-unchanged]

     [--[no-]skip-worktree]

     [--[no-]fsmonitor-valid]

     [--ignore-submodules]

     [--[no-]split-index]

     [--[no-|test-|force-]untracked-cache]

     [--[no-]fsmonitor]

     [--really-refresh] [--unresolve] [--again | -g]

     [--info-only] [--index-info]

     [-z] [--stdin] [--index-version <n>]

     [--verbose]

     [--] [<file>…]

--chmod=(+|-)x

Set the execute permissions on the updated files.

3.再次查看文件权限信息

100755 b0a1909819160a88cf723cba9b082a41638e19d7 0       work.sh
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值