关于与Git合作的几个问题

时间:2021-07-16 17:26:42

I am a web-developer. I am currently working as follows: connected via FTP to the site directory on the server => download project (part of project) => develop new modules => uploaded complete modules (few files) to the server. My colleagues are developing other modules on this site and use the same algorithm.

我是一名网络开发人员。我目前的工作方式如下:通过FTP连接到服务器上的站点目录=>下载项目(项目的一部分)=>开发新模块=>上传完整模块(少量文件)到服务器。我的同事正在开发此站点上的其他模块并使用相同的算法。

I know it's bad, and the old way. I want to organize the development process using a version control system (Git).

我知道这很糟糕,而且很老。我想使用版本控制系统(Git)来组织开发过程。

I've heard that it makes so: We have the application development process, there are two main branches of the master and the dev. My colleagues and I cloned main branch dev, create a local branch of a temporary new functionality or a patch, develop, make commits, then make the merge a temporary local branch with a main remote branch dev. 1) Am I right?

我听说它是​​这样的:我们有应用程序开发过程,master和dev有两个主要分支。我的同事和我克隆了主分支dev,创建了一个临时新功能或补丁的本地分支,开发,提交,然后使用主远程分支dev合并一个临时本地分支。 1)我是对的吗?

2) I know that branch dev and master working with files from one repository - one directory.

2)我知道分支dev和master使用来自一个存储库的文件 - 一个目录。

Document root of my site and document root of subdomen of my site - this is different directories

记录我的站点的根目录和我的站点的子目录的文档根目录 - 这是不同的目录

I want my main domain site had the current stable version of the site, but a subdomain of my site referred to the development version of the site. How is it organized? How to do it?

我希望我的主域名网站有当前稳定版本的网站,但我网站的子域名是指该网站的开发版本。它是如何组织的?怎么做?

3) If I am not mistaken, a central repository is typically stored on github.com How to link the main repository and directory site? Upload files from the repository to hosting manually ? Whether to keep the site's directory on git hub? It may be better to use a repository within the local network?

3)如果我没有弄错,*存储库通常存储在github.com上如何链接主存储库和目录站点?手动将文件从存储库上传到托管?是否将网站的目录保存在git hub上?在本地网络中使用存储库可能更好吗?

Thank you all

谢谢你们

1 个解决方案

#1


1  

Lots of good questions! To answer them one by one.

很多好问题!逐一回答。

Yes, your general understanding is right - that's one way to use Git. For a more detailed explanation of a workflow like this, check out Git-Flow: here and here. The branches are typically called master and develop. In addition to that, you will be working with feature and release branches.

是的,您的一般理解是正确的 - 这是使用Git的一种方式。有关此类工作流程的更详细说明,请查看Git-Flow:此处和此处。分支通常被称为主和分支。除此之外,您还将使用功能和发布分支。

With regards to your stable (master) and unstable (develop) branches in different directories, here's what you can do: Clone the repository twice, i.e. once in each directory on the server. In the stable directory, you check out the master branch, and in the unstable directory, you check out the develop branch. This way, you can keep both separate and also update them on demand. You could also look into tools/scripts that update/pull automatically whenever the branch is changed.

关于不同目录中的稳定(主)和不稳定(开发)分支,您可以执行以下操作:将存储库克隆两次,即在服务器上的每个目录中进行一次。在stable目录中,检查master分支,在unstable目录中,检查develop分支。这样,您可以将两者分开并根据需要更新它们。您还可以查看在更改分支时自动更新/拉取的工具/脚本。

For the hosting, there are several options, I'll list the most common/popular ones:

对于托管,有几个选项,我将列出最常见/最受欢迎的选项:

  • GitHub: By default (with free accounts), all repos on GitHub are public. This is great for open source, but might not be what you want. Paid accounts include private repos.
  • GitHub:默认情况下(使用免费帐户),GitHub上的所有回购都是公开的。这对开源很有用,但可能不是你想要的。付费帐户包括私人回购。
  • BitBucket: The free account here includes private repos as well, this might be better suited for you. There are probably other services that offer this as well.
  • BitBucket:这里的免费帐户也包括私人回购,这可能更适合你。可能还有其他服务提供此功能。
  • Hosting your own: You can use a paid tool like GitHub Enterprise or Atlassian Stash, or there are free/open source tools like GitLab that you can use to host your own repo. This might be the best if you plan to do more in this area, but it's also more complex to set up and maintain. Hosting your own has the advantage that you can easily deploy to your server through a post-hook.
  • 托管您自己的:您可以使用GitHub Enterprise或Atlassian Stash等付费工具,也可以使用GitLab等免费/开源工具来托管您自己的仓库。如果您计划在此区域执行更多操作,这可能是最好的,但设置和维护也更复杂。托管您自己的优势在于您可以通过后挂钩轻松部署到您的服务器。

I would start with something like BitBucket and then think about next steps.

我会从像BitBucket这样的东西开始,然后考虑下一步。

#1


1  

Lots of good questions! To answer them one by one.

很多好问题!逐一回答。

Yes, your general understanding is right - that's one way to use Git. For a more detailed explanation of a workflow like this, check out Git-Flow: here and here. The branches are typically called master and develop. In addition to that, you will be working with feature and release branches.

是的,您的一般理解是正确的 - 这是使用Git的一种方式。有关此类工作流程的更详细说明,请查看Git-Flow:此处和此处。分支通常被称为主和分支。除此之外,您还将使用功能和发布分支。

With regards to your stable (master) and unstable (develop) branches in different directories, here's what you can do: Clone the repository twice, i.e. once in each directory on the server. In the stable directory, you check out the master branch, and in the unstable directory, you check out the develop branch. This way, you can keep both separate and also update them on demand. You could also look into tools/scripts that update/pull automatically whenever the branch is changed.

关于不同目录中的稳定(主)和不稳定(开发)分支,您可以执行以下操作:将存储库克隆两次,即在服务器上的每个目录中进行一次。在stable目录中,检查master分支,在unstable目录中,检查develop分支。这样,您可以将两者分开并根据需要更新它们。您还可以查看在更改分支时自动更新/拉取的工具/脚本。

For the hosting, there are several options, I'll list the most common/popular ones:

对于托管,有几个选项,我将列出最常见/最受欢迎的选项:

  • GitHub: By default (with free accounts), all repos on GitHub are public. This is great for open source, but might not be what you want. Paid accounts include private repos.
  • GitHub:默认情况下(使用免费帐户),GitHub上的所有回购都是公开的。这对开源很有用,但可能不是你想要的。付费帐户包括私人回购。
  • BitBucket: The free account here includes private repos as well, this might be better suited for you. There are probably other services that offer this as well.
  • BitBucket:这里的免费帐户也包括私人回购,这可能更适合你。可能还有其他服务提供此功能。
  • Hosting your own: You can use a paid tool like GitHub Enterprise or Atlassian Stash, or there are free/open source tools like GitLab that you can use to host your own repo. This might be the best if you plan to do more in this area, but it's also more complex to set up and maintain. Hosting your own has the advantage that you can easily deploy to your server through a post-hook.
  • 托管您自己的:您可以使用GitHub Enterprise或Atlassian Stash等付费工具,也可以使用GitLab等免费/开源工具来托管您自己的仓库。如果您计划在此区域执行更多操作,这可能是最好的,但设置和维护也更复杂。托管您自己的优势在于您可以通过后挂钩轻松部署到您的服务器。

I would start with something like BitBucket and then think about next steps.

我会从像BitBucket这样的东西开始,然后考虑下一步。