如何在github chmod=+x 中制作上传文件?然后使用 wget 命令下载文件,保留 github 模式下的可执行文件集?

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?

我的 OS 是 Ubuntu 20.04

我经历过这个postHow to add chmod permissions to file in GIT?

我有的就是这个文件https://github.com/PRATAP-KUMAR/focalgdm3/blob/master/focalgdm3

我要找的是

chmod +x 这样,一旦我通过 link wget https://raw.githubusercontent.com/PRATAP-KUMAR/focalgdm3/master/focalgdm3 从 github 下载文件,它就可以在 Ubuntu 20.04

我尝试了 git update-index 命令但出现错误..

pratap@i7-6550U:~$ git update-index --chmod=+x focalgdm3fatal: not a git repository (or any of the parent directories): .gitpratap@i7-6550U:~$ 

寻找一步一步的过程..

请在执行 git update-index 命令之前转到 github.com/PRATAP-KUMAR/focalgdm3 目录。

$ cd github.com/PRATAP-KUMAR/focalgdm3
$ git update-index --chmod=+x focalgdm3

I have added the file to github by dragging the file from my computer to github upload existing file page.

然后clone the repository,本地:

cd /path/to/local/clone
git add --chmod=+x myFile
git config --global user.name "My name"
git config --global user.email "my@email.com" (the one used for GitHub account)
git commit -m "Made myFile executable"
git push

Antwane's 中所述,通过 HTTP 的 wget 将不起作用。
但是从“Download executable script from GitHub preserving +x permissions”来看,你可以:

  • 从 GitHub 存储库获取 tarball(不需要 Git)
  • 从中提取单个文件:然后应保留其权限。

即:

wget -qO - https://github.com/<user>/repo>/archive/master.tar.gz | \
tar zx --strip-components=1 <repo>-master/<filename>

<user> 替换为您的 GitHub 用户名,将 <repo> 替换为您的存储库名称

你的情况:

wget -qO - https://github.com/PRATAP-KUMAR/focalgdm3/archive/master.tar.gz | \
tar zx --strip-components=1 focalgdm3-master/focalgdm3

据我了解,您希望在使用 wget 下载后立即准备好可执行文件 运行。类似的东西:

wget https://raw.githubusercontent.com/PRATAP-KUMAR/focalgdm3/master/focalgdm3
./focalgdm3

这是不可能的(主要是出于安全原因),因为 HTTP 协议(​​当您从 GitHub 下载文件时使用)没有关于您文件的 RWX 标志的信息(参见 https://serverfault.com/a/863523/398223

可能的解决方案是在安装过程中添加 chmod 命令

wget https://raw.githubusercontent.com/PRATAP-KUMAR/focalgdm3/master/focalgdm3
chmod +x focalgdm3
./focalgdm3

您还可以将 focalgdm3 二进制文件放入 zip 或 .tar.gz 存档(保留可执行标志),并将其放入 GitHub 存储库,以便您的用户可以下载,提取并 运行 程序。