如何将 U 盘作为 Git 存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20628420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:29:15  来源:igfitidea点击:

How to make USB pendrive as a Git Repository?

gitusbrepositoryusb-drive

提问by VonC

I want to make USB Pendrive as a Git repository for gathering information.

我想把 USB Pendrive 作为一个 Git 存储库来收集信息。

Suppose if we make our Pen drive as a Git repository: Can we incorporate audio, video files in it?

假设我们将笔式驱动器作为 Git 存储库:我们可以在其中合并音频、视频文件吗?

回答by VonC

The best practice is to create a baregit repodirectly in your USB key, and consider that repo as your remote repo.

最佳做法是直接在您的 USB 密钥中创建一个git 存储库,并将该存储库视为您的远程存储库。

cd /path/to/your/usb/key
git init --bare myrepo
ls myrepo.git

That means you are cloning/pulling from that repo onto your local harddrive, and you are pushing back to the bare repo on your USB key.

这意味着您正在将该存储库克隆/拉到本地硬盘驱动器上,并且您正在推回 USB 密钥上的裸存储库。

Note that myrepo.gitfolder on said key, which contains your bare repo, don't change the nature of that key.
You can still copy any other file (audio, video, ...) you want on that key, outsideof the myrepo.gitfolder.
I wouldn't recommend pushing to that repo binary files (audio, video, ...) though, as that would make any clone quite cumbersome because of the size of the repo.

请注意,myrepo.git包含您的裸仓库的所述密钥上的文件夹不会更改该密钥的性质。
您仍然可以将该键上的任何其他文件(音频、视频等)复制到文件夹之外myrepo.git
不过,我不建议推送到该 repo 二进制文件(音频、视频等),因为由于 repo 的大小,这会使任何克隆变得非常麻烦。

回答by Jepessen

Every git project is a repository, from which you can push, pull ecc. So you can create the repository wherever you want. You can incorporate every kind of file. Take care of repository size, because these binary files have not little size, generally speaking. If the pendrive became full, you can simply copy the repository to another drive that have enough space and use that.

每个 git 项目都是一个存储库,您可以从中推送、拉取 ecc。因此,您可以在任何地方创建存储库。您可以合并各种文件。注意存储库的大小,因为这些二进制文件的大小一般不小。如果 pendrive 已满,您可以简单地将存储库复制到另一个有足够空间的驱动器并使用它。