Git从一个用户帐户拉到另一个用户帐户

时间:2021-05-06 16:24:05

I access a linux server by ssh. I have two user accounts on that server. One user for development and one user for production.

我通过ssh访问linux服务器。我在该服务器上有两个用户帐户。一个用于开发的用户和一个用于生产的用户。

It is about a webapp which runs on public_html folder of each user and I access the application by visiting server_address/~user_account_name

它是关于在每个用户的public_html文件夹上运行的webapp,我通过访问server_address / ~user_account_name访问该应用程序

On those accounts using the ssh, I've made some git repositories. In order to make updates to production account, i do a git log --name-status -n3 and copy the files which were modified.

在使用ssh的那些帐户上,我已经制作了一些git存储库。为了更新生产帐户,我执行git log --name-status -n3并复制已修改的文件。

The thing is that I'll like to pull from one account to another but I don't know how to do it.

问题是我想从一个帐户拉到另一个帐户,但我不知道该怎么做。

Can you give me some advices?

你能给我一些建议吗?

1 个解决方案

#1


0  

Sure, that's easy. First, you have to make sure that the public_html directory within each user account is a git repository. Probably the best way to do this is to

当然,这很容易。首先,您必须确保每个用户帐户中的public_html目录是一个git存储库。可能最好的方法是

cd /home/production
mv public_html public_html.backup
git clone /home/development/public_html public_html

In order for this to work, you may have to adjust the permissions on the development public_html repository. I'd probably suggest making a group called "website" or something, adding both the production and development users to it, and running

为了使其工作,您可能必须调整开发public_html存储库的权限。我可能会建议创建一个名为“网站”的组,或者将生产和开发用户添加到其中,然后运行

cd /home/development
chgrp --recursive website public_html
chmod --recursive g+wX public_html

Afterwards, whenever you need to copy files from the development site to the production site, you can run

之后,无论何时需要将文件从开发站点复制到生产站点,都可以运行

cd /home/production/public_html
git pull origin

You may also be interested in this blog post of mine in which I describe how I manage my website on staging and production servers using git. It's a slightly fancier approach because there are multiple computers involved, but I've found it to work pretty well.

您可能也对我的博客文章感兴趣,其中我描述了如何使用git在登台和生产服务器上管理我的网站。这是一个稍微有点发达的方法,因为涉及多台计算机,但我发现它工作得很好。

#1


0  

Sure, that's easy. First, you have to make sure that the public_html directory within each user account is a git repository. Probably the best way to do this is to

当然,这很容易。首先,您必须确保每个用户帐户中的public_html目录是一个git存储库。可能最好的方法是

cd /home/production
mv public_html public_html.backup
git clone /home/development/public_html public_html

In order for this to work, you may have to adjust the permissions on the development public_html repository. I'd probably suggest making a group called "website" or something, adding both the production and development users to it, and running

为了使其工作,您可能必须调整开发public_html存储库的权限。我可能会建议创建一个名为“网站”的组,或者将生产和开发用户添加到其中,然后运行

cd /home/development
chgrp --recursive website public_html
chmod --recursive g+wX public_html

Afterwards, whenever you need to copy files from the development site to the production site, you can run

之后,无论何时需要将文件从开发站点复制到生产站点,都可以运行

cd /home/production/public_html
git pull origin

You may also be interested in this blog post of mine in which I describe how I manage my website on staging and production servers using git. It's a slightly fancier approach because there are multiple computers involved, but I've found it to work pretty well.

您可能也对我的博客文章感兴趣,其中我描述了如何使用git在登台和生产服务器上管理我的网站。这是一个稍微有点发达的方法,因为涉及多台计算机,但我发现它工作得很好。