How to make a uploaded file in github chmod=+x? and then download the file with wget command preserving the executable set in github mode?
我的操作系统是Ubuntu 20.04
我已经阅读了这篇文章如何在GIT中向文件添加chmod权限?
我所拥有的是这个文件https://github.com/PRATAP-KUMAR/focalgdm3/blob/master/focalgdm3
我正在寻找的是
我尝试了
1 | pratap@i7-6550U:~$ git update-index --chmod=+x focalgdm3fatal: not a git repository (or any of the parent directories): .gitpratap@i7-6550U:~$ |
正在逐步查找程序。.
I have added the file to github by dragging the file from my computer to github upload existing file page.
然后在本地克隆存储库:
1 2 3 4 5 6 | cd /path/to/local/clone git add --chmod=+x myFile git config --global user.name"My name" git config --global user.email"[email protected]" (the one used for GitHub account) git commit -m"Made myFile executable" git push |
如Antwane的答案所述,通过HTTP的wget无法正常工作。
但是,如从"从GitHub下载可执行脚本以保留x权限"所见,您可以:
- 从GitHub存储库获取压缩包(无需Git)
- 从其中提取单个文件:然后应保留其许可权。
即:
1 2 | wget -qO - https://github.com/<user>/repo>/archive/master.tar.gz | \\ tar zx --strip-components=1 <repo>-master/<filename> |
用您的GitHub用户名替换
替换
在您的情况下:
1 2 | wget -qO - https://github.com/PRATAP-KUMAR/focalgdm3/archive/master.tar.gz | \\ tar zx --strip-components=1 focalgdm3-master/focalgdm3 |
据我了解,您希望使用
1 2 | wget https://raw.githubusercontent.com/PRATAP-KUMAR/focalgdm3/master/focalgdm3 ./focalgdm3 |
这是不可能的(主要出于安全原因),因为HTTP协议(从GitHub下载文件时使用)没有有关文件的RWX标志的信息(请参阅https://serverfault.com/a/863523/398223)
可能的解决方案是在安装过程中添加
1 2 3 | wget https://raw.githubusercontent.com/PRATAP-KUMAR/focalgdm3/master/focalgdm3 chmod +x focalgdm3 ./focalgdm3 |
您还可以将
在执行
1 2 | $ cd github.com/PRATAP-KUMAR/focalgdm3 $ git update-index --chmod=+x focalgdm3 |