简体   繁体   English

如何集成服务器文件的版本控制?

[英]How to integrate version control for server files?

I'm fairly new to using git and I've only cloned git repositories to local folders before. 我对使用git相当陌生,之前只将git存储库克隆到本地文件夹中。 But now I am working off files that are on a remote server. 但是现在我正在处理远程服务器上的文件。 We run all our simulations there and use an SSH tunnel to connect and transfer files. 我们在那里运行所有模拟,并使用SSH隧道连接和传输文件。

I'm wondering if there is a way to use version control for our project, but not sure how or if this can be done? 我想知道是否有一种方法可以为我们的项目使用版本控制,但是不确定如何或是否可以做到这一点?

Everything I've found so far seems to be describing how to integrate local and remote repositories. 到目前为止,我发现的所有内容似乎都在描述如何集成本地和远程存储库。 But in our case both are remote. 但就我们而言,两者都是遥远的。

您还可以让服务器从存储库中获取文件,因此您可以将本地文件推送到远程存储库,也可以从远程存储库中提取服务器文件。

I'm not sure that understand you completely. 我不确定是否完全了解您。 You have your local git repo and some remote git repository as well? 您有本地git repo和一些远程git存储库吗? So you can commit and push commits to remote repo as well I suppose. 因此,我想您也可以将提交提交和推送到远程仓库。

You can clone that repo on your server and use it on your server as well. 您可以在服务器上克隆该存储库,也可以在服务器上使用它。

  1. Just add command 'git pull' to the cron scheduler or Windows task scheduler to run over time and pull new commits from the git server. 只需将命令'git pull'添加到cron计划程序或Windows任务计划程序中即可运行,并从git服务器中提取新提交。 It's easiest way but not very nice. 这是最简单的方法,但不是很好。

  2. You can use git hooks to run commands on the git server and run the same command on the server after receiving commit. 您可以使用git hooks在git服务器上运行命令,并在收到提交后在服务器上运行同一命令。 It's a standard way to do such a things. 这是执行此类操作的标准方法。

Take a look here: http://githooks.com/ 在这里看看: http : //githooks.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM