git - 如何在 github chmod=+x 中制作上传文件?然后使用 wget 命令下载文件,保留 github 模式下的可执行文件集?
问题描述
我的操作系统是 Ubuntu 20.04
我已经阅读了这篇文章How to add chmod permissions to file in GIT?
我所拥有的是这个文件https://github.com/PRATAP-KUMAR/focalgdm3/blob/master/focalgdm3
我要找的是
chmod +x
这样,一旦我通过此链接 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:~$
正在寻找一步一步的过程..
解决方案
我已通过将文件从我的计算机拖动到 github 上传现有文件页面来将文件添加到 github。
然后克隆存储库,并在本地克隆:
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的回答中所解释的,通过 HTTP 的 wget 将不起作用。
但是从“从 GitHub 下载可执行脚本保留 +x 权限”中可以看出,您可以:
- 从 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
推荐阅读
- xcode - 在 XCode 中找不到 Mapbox 框架错误
- c++ - 如何将 ocaml 代码编译为本机以供 C++ 使用
- assembly - 使用 AVR 反转字节中的位
- postgresql - 如何配置 PostgreSQL 以接受除 postgres / admin 之外的所有传入连接
- javascript - 在新页面中打开媒体而不是下载(MediaRecorder-sample)
- sql - 如何从表 B 值更新表 A 值?
- android - 找不到符号 CountryFragmentBindingImpl
- r - 有没有更快的方法来合并数据帧和循环组合?
- java - Java PreparedStatement 保留表名大小写
- php - 如何解决未捕获的错误:调用未定义的方法 stdClass::query()