制作远程 git 存储库的本地副本

发布于 2024-12-01 01:55:51 字数 285 浏览 1 评论 0原文

我对版本控制的术语或实践和程序不是很熟悉。

这是我想要做的:

  1. 我想从互联网上的 git 存储库下载一个文件夹。克隆是正确的方法吗?克隆不会保留不必要的元数据文件吗?有没有办法进行“干净”下载?

  2. 我想设置一个包含此文件夹的本地存储库,我现在可以在其中使用版本控制。也就是说,当我进行提交时,我的本地存储库会更新。

  3. 最后,我希望这个本地存储库可以在本地网络上访问,以便我也可以从 LAN 上的任何其他计算机上下载它。

I am not very familiar with the terminology or practices and procedures of version control.

Here is what I want to do :

  1. I want to download a folder from a git repository from the Internet. Is cloning the right way to do it ? WOn't cloning keep the unnecessary meta-data files ? Is there a way to do a "clean" download ?

  2. I want to set up a local repository that contains this folder on which I can now use version control. That is, when I do a commit, my local repository gets updated.

  3. Finally, I want this local repo to be accessible on the local network, so that I can download it from any other machine on the LAN too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

月亮是我掰弯的 2024-12-08 01:55:51
  1. 克隆是正确的方法,但会下载远程 Git 存储库的所有目录。
    请参阅 Git 参考的 git clone
  2. 克隆命令将创建一个存储库,其中已检出工作树,以及代表完整存储库的 .git
  3. 您至少需要有一个共享路径,以便其他人克隆/拉取/推送您的存储库。
    请参阅 git 本地协议

如果您不熟悉这些操作,我建议您按照 git immersion< 提出的简单练习进行操作/强>。

  1. Cloning is the right way, but will download all the directories of your remote Git repo.
    See git clone of Git Reference.
  2. The clone command will create a repo with a working tree already checked out in it, and a .git representing your full repo
  3. You need to have at least a shared path in order for other to clone/pull/push your repo.
    See git local protocol.

If you are not familiar with those operations, I would recommend you to follow the simple exercices proposed by git immersion.

GRAY°灰色天空 2024-12-08 01:55:51

您无法从 git 存储库下载单个文件或文件夹,因为 git 跟踪整个项目的完整状态,而不仅仅是单个文件。可以从远程存储库仅克隆有限的修订集(称为浅克隆),但此类克隆仅限于有限的操作集,例如,您无法从浅克隆克隆,或从这样的回购协议。

如果 git repo 的大小困扰您,您可以使用 git gc 来让 git 重新组织对象数据库,这有时可以获得大小改进。

当您想要拥有本地缓存​​时,可以使用 git clone --mirror $REMOTE_URL 来创建一个克隆,该克隆

您可以从这个本地缓存存储库克隆新的工作存储库,或者直接推送到上游存储库(您需要在你的工作副本中 git remote add upper $REMOTE_URL 来添加上游仓库的链接,之后你可以 git push upper),或者你也可以推送到本地缓存repo,并推送到上游repo从那里。

You can't download single files or folders from a git repo, since git tracks the full state of a project as a whole, not just single files. There is a possibility to clone only a limited set of revisions (called shallow clone) from a remote repositoy, but such clones are restricted to a limited set of operations, for example you can't clone from a shallow clone, or push something from such a repo.

If the size of a git repo bothers you, you can git gc to make git reorganize the object database, which sometimes can get size improvements.

When you want to have a local cache, you can use git clone --mirror $REMOTE_URL to create a clone, which

You can clone new working repos from this local cache repo, and either push directly into the upstream repo (you need to git remote add upstream $REMOTE_URL in your working copy to add the link to the upstream repo, afterwards you can git push upstream), or you can push into the local cache repo, and push to the upstream repo from there.

_蜘蛛 2024-12-08 01:55:51

虽然 git clone 适合步骤 1 和 2。 2、您可能需要阅读一些 git 书籍,例如 Progit / Community 书籍等,以正确了解步骤 3 的最佳方法和 git 哲学。

Git 作为分布式 VCS,努力避免您的“可在本地网络上访问的本地存储库”可能建议的“单一中央存储库”。您可以在网络上拥有一个裸存储库,这允许许多从中推送/拉取,但这与在网络上拥有本地存储库(带有工作目录)和不同>只有您像本地驱动器一样使用它。

While git clone is the right for steps 1 & 2, you may need to have a read of a few of the git books e.g. Progit / Community book etc. to get a proper flavour of the best approach to step 3, and the git philosophy.

Git, as a distributed VCS, tries hard to avoid the "single central repository" that your "local repo to be accessible on the local network" might suggest. You can have a bare repo on the network, which allows many to push/pull from it, but this isn't the same as having your local repo on the network, with working directory, and only you using it as if it were a local drive.

花开半夏魅人心 2024-12-08 01:55:51

是的,“git克隆”是正确的选择。这将为您提供所有数据并允许您进行提交。只要新的存储库在 LAN 上可见,其他计算机就应该能够从中克隆。

Yes 'git clone' is the way to go. This will get you all the data and allow you to do commits. As long as the new repo is visible on the LAN, other computers should be able to clone from it as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文