[英]How should I setup my Git repositories to be able to push and still have a working directory at both places?
I have a personal laptop and a development box and want a setup with following things in mind: 我有一台个人笔记本电脑和一个开发箱,想要进行以下设置:
--bare
repo.) --bare
。) I tried initializing a Git repo with code on dev box and cloned in on my laptop. 我尝试使用开发箱上的代码初始化Git存储库,然后克隆到笔记本电脑上。 I could not push changes to dev box though.
我无法将更改推送到开发箱。 It gives me the error that I am pushing to a non-bare repo.
它给了我我推向一个非裸仓库的错误。
Then I tried --bare
repo and it worked, but then I cannot run the code sitting on dev box. 然后我尝试了
--bare
repo并成功了,但是后来我无法运行位于开发箱上的代码。 (Or can I?) (或者我可以吗?)
Any ideas on how to achieve this kind of setup? 关于如何实现这种设置的任何想法?
One way to solve this is to create a third repo (that you can think of as the "main" repository) that is --bare
. 解决此问题的一种方法是创建第三个仓库
--bare
(您可以将其视为“主要”存储库)。 To share changes, you can push to the bare repository from one machine and pull from the other. 要共享更改,您可以从一台计算机推送到裸存储库,然后从另一台计算机提取。
If you put this bare repo on the web box, then you can set up a post-commit hook to automatically extract the files from the main repo to the (non-bare) repo that's used by the web server. 如果将此裸仓库放置在Web框上,则可以设置提交后钩子,以将文件从主仓库自动提取到Web服务器使用的(非裸仓库)仓库。
I usually don't set up such a post-commit hook, but my workflow is generally: 我通常不设置这样的提交后挂钩,但是我的工作流程通常是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.