我不明白的关于 Git 的事情 - 推拉和嵌套存储库
我有这样的场景:
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技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不应该需要那种 f 设置的子模块,在这种设置中,您将一个存储库从一个环境(Dev)复制到另一个环境(Staging),有点像“当移动时,计算机之间的 git 存储库同步?”。
您的过程(添加远程并推送)是正确的,但您应该:
(或者您可以直接从远程裸仓库)
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:
(Or you can directly fetch from the remote bare repo)
关于子模块,我建议阅读 ProGit 的相关章节
About submodules, I suggest reading the relevant chapter of ProGit
当您推送到远程存储库时,它不会自动更新临时服务器上的工作副本。通过使用重置命令,您可以将工作副本更新为之前推送的 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.