Git 对于没有 .git 的单个文件
Git for single file without .git
假设我有一个脚本想要 git。据我所知,我必须创建一个包含此脚本和 .git
.
的文件夹
- 有没有办法只拥有脚本本身?这意味着有某种 header/footer 来处理 git 东西。
- 如果没有,另一种选择是使用一个额外的文件来处理 git.
.git integral git 工作和存储信息的方式。您将需要它以某种方式使用 git.
如果我没理解错的话,你想要一个受版本控制的脚本,但脚本所在的文件夹必须是空的。
为此,我们可以在父文件夹中创建一个 git 存储库,子目录只有脚本。
parentDirectoryUnderVC/
.git/
myScriptProjectWithOnlyMyScriptInIt/
myScript.whatever
实现版本控制的单文件-in-otherwise-empty-repo 的一种方法是在某处有一个裸repo,然后将其检出到您只需要一个文件的文件夹中。
正如解释的那样here
To checkout everything from your HEAD (not index) to a specific out directory:
git --work-tree=/path/to/outputdir checkout HEAD -- .
假设我有一个脚本想要 git。据我所知,我必须创建一个包含此脚本和 .git
.
- 有没有办法只拥有脚本本身?这意味着有某种 header/footer 来处理 git 东西。
- 如果没有,另一种选择是使用一个额外的文件来处理 git.
.git integral git 工作和存储信息的方式。您将需要它以某种方式使用 git.
如果我没理解错的话,你想要一个受版本控制的脚本,但脚本所在的文件夹必须是空的。
为此,我们可以在父文件夹中创建一个 git 存储库,子目录只有脚本。
parentDirectoryUnderVC/
.git/
myScriptProjectWithOnlyMyScriptInIt/
myScript.whatever
实现版本控制的单文件-in-otherwise-empty-repo 的一种方法是在某处有一个裸repo,然后将其检出到您只需要一个文件的文件夹中。
正如解释的那样here
To checkout everything from your HEAD (not index) to a specific out directory:
git --work-tree=/path/to/outputdir checkout HEAD -- .