“获取-全部”在 git bare 存储库中,不会将本地分支同步到远程分支
我正在尝试定期同步 git bare 存储库,我的本地分支是使用“--track”选项创建的。这是我的配置(没有不必要的东西):
[core]
bare = true
[remote "origin"]
url = [email protected]:Ummon/D-LAN.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "website"]
remote = origin
merge = refs/heads/website
我必须使用“cp”命令来更新本地分支:
git fetch --all
cp -r refs/remotes/origin/* refs/heads
是否有更优雅的解决方案?
I'm trying to synchronize periodically a git bare repository, my local branches are created using the "--track" option. here is my config (without unnecessary things):
[core]
bare = true
[remote "origin"]
url = [email protected]:Ummon/D-LAN.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "website"]
remote = origin
merge = refs/heads/website
I must use the 'cp' command to update the local branches:
git fetch --all
cp -r refs/remotes/origin/* refs/heads
Is there a more elegant solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要复制参考文件(糟糕!),而是使用 git update-ref
请注意,在推送而不是拉取时,您可以轻松地将所需内容保存到裸存储库中。
使用这个:
创建您想要完全同步的裸存储库
现在,要将所有分支同步到裸克隆镜像,请使用
注意,这还将删除不在源存储库中但(仍然)在裸克隆中的任何头。另请注意,您可以使用 send-pack 而不是在那里推送,因为这个接口相当低级,并且实际上是由 send-pack
HTH
实现的,正如评论者指出的那样,我稍微回避了这个主题,即似乎不可能立即执行相反的操作。然而,通过做一些稍微高级的事情,你可以离目标还有很长的路要走,比如:
1. 简单、安全并且相当平淡。
设置“url=git://your.server/project.git”,例如
我确保引用是在一个相当安全的位置创建的。效果和doing非常相似。
所以没有什么太多,但是它向您展示了如何使用管道命令来实现它,所以我们现在可以根据我们的需求调整它们:
2.现在直接提取到本地分支(头)
如果您确定知道自己在做什么,您可以使用以下样式在本地复制分支:
3. 完整的 monty
这也可以组合起来,这样您也可以有一个远程定义。我建议这样做,因为这意味着本地分支实际上正在跟踪来自远程的分支,如果您不小心使用这些强大的获取命令破坏了这些分支上的一些本地提交,您将拥有更好的隔离/恢复选项< /em>
玩得开心,HTH
Instead of copying the ref files around (bad bad!) use
git update-ref
Note that you can have what you wanted pretty easily to a bare repository when pushing instead of pulling.
Use this:
to create the bare repository that you want to keep completely in synch
Now, to synch all the branches to the bareclone mirror, use
NOTE that this will also remove any heads that aren't in the source repo but (still) are in the bareclone. Also note that you can use send-pack instead of push there because this interface is rather lowlevel and actually implemented by send-pack
HTH
As the commenter noted, I slighly avoided the subject that it doesn't seem possible at once to do the inverse. However, you can get a long ways towards the goal by doing something slightly advanced like:
1. Simple, safe and pretty unexciting.
Set `url=git://your.server/project.git' e.g.
I made sure that the refs are created in a moderately safe location. The effect very similar to doing.
So there is nothing much, but it shows you how to use plumbing commands to achieve it, so we can now adapt them to our needs:
2. Fetch directly into local branches (heads)
Now if you are sure you know what you're doing you can use the following style to get the branches duplicated locally:
3. The full monty
This could also be combined, so you can have a remote definition too. I'd recommend that because it will mean that the local branches are actually tracking the ones from the remotes, and you'll have better insulation/recovery options if you accidentally clobber some of the local commits on these branches with these powerful fetch commands
Have fun, HTH