如何制作镜像上游存储库的本地git存储库? [英] How to make a local git repository that mirrors an upstream repository?
问题描述
我需要镜像上游存储库并将其用作所有项目的本地存储库。标准是:
-
能够从上游存储库中获取/获取。
-
人们可以克隆这个本地存储库并在他们自己的项目上工作;然后他们可以将他们的项目/分支/变更推送到本地存储库(我们不会推回上游存储库)。
当人们从这个本地存储库,他们应该能够看到上游存储库中的更改。
我尝试使用:
git clone --bare
克隆上游存储库,然后:
git fetch
更新。但是这个本地存储库的克隆将不会看到更新。从我所知道的情况来看,在本地的裸机存储库中,origin / master已更新,但HEAD和master停留在他们所在的位置。有任何想法吗?感谢!
您是否试过使用克隆git clone --mirror
?
从 git克隆手册页:
设置源存储库的镜像。这意味着 - 不过。与--bare相比,--mirror不仅将源的本地分支映射到目标的本地分支,还映射所有参考(包括远程跟踪分支,注释等),并设置refspec配置,以便所有这些参考被目标库中的git远程更新覆盖。
I need to mirror an upstream repository and use this as our local repository for all the projects. The criteria are:
be able to pull/fetch from the upstream repository.
people can clone this local repository and work on their own projects; and then they can push their projects/branches/changes to this local repository (we don't push back to the upstream repository).
when people pull from this local repository, they should be able to see the changes in the upstream repository.
I tried to use:
git clone --bare
to clone the upstream repository and then:
git fetch
to update. But clones of this local repository won't see the updates. From what I can tell, in the local "bare" repository, "origin/master" got updated, but "HEAD" and "master" stays at where they were. Any ideas? Thanks!
Have you tried cloning with git clone --mirror
?
From the git clone man page:
Set up a mirror of the source repository. This implies --bare. Compared to --bare, --mirror not only maps local branches of the source to local branches of the target, it maps all refs (including remote-tracking branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a git remote update in the target repository.
这篇关于如何制作镜像上游存储库的本地git存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!