首页 > 解决方案 > 是否可以使用一个 git repo 并从两个不同的分支运行两个站点?

问题描述

我有一个项目,为此我设置了一个 git 存储库。我有两个与我合作的分支:主分支和开发分支。这都是在我的服务器上设置的。我想做的是从子域访问和测试我的开发分支,当一切正常时,合并到运行主站点的主站点。例如:

主分支:example.com

开发分支:dev.example.com

这可能吗?我的网站是一个在 Node 上运行的 Express 应用程序,我在 Ubuntu 20.04 服务器上使用 Nginx,主域和子域位于不同的服务器块上。任何正确方向的帮助或指示将不胜感激。

标签: gitnginxsubdomainproduction

解决方案


是的,这很有可能。请参阅下面的 cmd。

$ cd /tmp
$ mkdir abc
$ cd abc
$ git init
Initialized empty Git repository in /tmp/abc/.git/
$ echo testing > README
$ git add README
$ git commit -m 'first commit'
[master (root-commit) e675a97] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 README
$ cd ..
$ git clone abc def
Cloning into 'def'...
done.
$ cd def
$ ls
README
$ 

参考:https ://www.reddit.com/r/git/comments/5giehg/is_it_possible_to_have_a_remote_thats_on_the_same/


推荐阅读