我不明白的关于 Git 的事情 - 推拉和嵌套存储库

发布于 2024-12-08 23:15:36 字数 599 浏览 0 评论 0原文

我有这样的场景:

Dev 是我用来开发的机器,我在它上面创建了一个 git 存储库并定期提交。

Staging 是一个服务器,我用它来上传我的工作的“稳定”版本,我也在那里创建了一个存储库,并

在需要时 将此服务器添加到 Dev 远程存储库中要推送,我只需使用 $ git push Staging master ,这会立即出现在服务器中,但为了使用新代码,我需要执行 $ git reset --hard HEAD 否则 git 认为我已经编辑了文件暂存并且我没有“新”文件。

我也没有得到 Git 中子模块的部分 - 我尝试了一些技术,主要是 git submodule add https://github.com/documentcloud/underscore.git local/sub/dir/underscore,但除了当前系统的转储之外,我没有得到任何结果$PATH 值。

非常感谢帮助! :)

I have this scenario:

Dev is my machine which I use to develop on, I created a git repo on it and commit to it regularly.

Staging is a server which I use to upload "stable" versions of my work to, I created a repo there too and added this server to the Dev remote repos

Whenever I want to push I simply use $ git push Staging master, this appears in the server immediately but in order to use the new code I need to do $ git reset --hard HEAD otherwise git thinks that I've edited the files on Staging and I don't have the "new" files.

I'm also not getting the part of Submodules in Git - I've tried a few techniques, mainly git submodule add https://github.com/documentcloud/underscore.git local/sub/dir/underscore, but I'm not getting any results except a dump of my current system $PATH value.

Help would be very appreciated! :)

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

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

发布评论

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

评论(3

层林尽染 2024-12-15 23:15:36

您不应该需要那种 f 设置的子模块,在这种设置中,您将一个存储库从一个环境(Dev)复制到另一个环境(Staging),有点像“​​当移动时,计算机之间的 git 存储库同步?”。

您的过程(添加远程并推送)是正确的,但您应该:

  • 推送到 远程存储库
  • 有一个接收后挂钩,能够使用最新的commi内容更新单独的工作树。

(或者您可以直接从远程裸仓库

You shouldn't need submodule for that kind f setup, where you replicate one repo from one environment (Dev) to another (Staging), a bit like "git repository sync between computers, when moving around?".

Your process (add a remote and push) is correct, except you should:

  • push to a remote bare repo
  • have a post-receive hook able to update a separate working tree with the latest commi contents.

(Or you can directly fetch from the remote bare repo)

土豪 2024-12-15 23:15:36

关于子模块,我建议阅读 ProGit 的相关章节

About submodules, I suggest reading the relevant chapter of ProGit

楠木可依 2024-12-15 23:15:36

当您推送到远程存储库时,它不会自动更新临时服务器上的工作副本。通过使用重置命令,您可以将工作副本更新为之前推送的 HEAD 修订版。

我认为您可以通过服务器端的一个钩子来简化此设置,该钩子在推送后执行。

When you push to the remote repo, it does not automatically update the working copy on the staging server. By using the reset command, you update your working copy to the HEAD revision, which you have pushed before.

I think you can easy this setup with a hook on the server side which is executed after the push.

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