简体   繁体   English

在不使用github的情况下为多个用户设置本地Git存储库

[英]Setting up a local Git repository without using github for multiple users

I am trying to set up a local Git repository on a secure server (which is why I can't use github at all). 我试图在安全服务器上设置本地Git存储库(这就是为什么我根本无法使用github的原因)。 I am a git newbie. 我是git新手。 It is for multiple projects, and each project directory will contain the .git file. 它用于多个项目,并且每个项目目录都将包含.git文件。 I have come up with a model which seems to work for a single user, but I don't think this will translate well for multiple users. 我提出了一个似乎适用于单个用户的模型,但是我认为这不能很好地适用于多个用户。 In each project I have created a 'development' branch which is where code development and testing will take place. 在每个项目中,我都创建了一个“开发”分支,在该分支中将进行代码开发和测试。 When we are happy with this we will merge to the master branch which is where the routine programs will be run from. 当我们对此感到满意时,我们将合并到master分支,在该分支中将运行常规程序。 The workflow is: 工作流程为:

On branch development: 关于分支发展:

Make changes to text.txt 对text.txt进行更改

git add python.py
git commit -m "made change to python.py"

Now we run python.py from the development branch to test if these changes worked. 现在,我们从开发分支运行python.py,以测试这些更改是否有效。 If not we can either restore or carry on developing. 如果没有,我们可以恢复或继续发展。 When we are happy: 当我们高兴时:

git checkout master
git merge development

Now we can run our newly developed program from our master branch safe in the knowledge that it works. 现在,我们可以在主分支机构安全运行的前提下运行新开发的程序。

However, this is fine when I am working by myself but this model needs to accommodate for more users developing the code. 但是,当我自己工作时很好,但是此模型需要容纳更多的用户来开发代码。 This is where I am confused. 这就是我感到困惑的地方。 Is this a good start off system or would cloning our repository onto a local machine be a better way when multiple people are using it? 这是一个很好的启动系统吗?或者当多个人使用它时,将我们的存储库克隆到本地计算机上会是更好的方法吗?

If two people are working on the same thing at the same time on the development branch then when adding to the staging area/committing, some changes will be lost. 如果两个人在开发分支上同时处理同一件事,那么在添加到暂存区/提交时,某些更改将丢失。

Therefore should we clone to a local machine, make our changes, do our tests then push back to the local repository for a user to review these changes? 因此,我们应该克隆到本地计算机上进行更改,然后进行测试,然后将其推送回本地存储库以供用户查看这些更改吗? The issue I see with this is we are using windows machines... and we ssh into a linux ubuntu server which is where we do our work. 我看到的问题是我们正在使用Windows机器...并且我们将ssh放入Linux ubuntu服务器中,这是我们进行工作的地方。 Therefore our windows machines do not have the necessary files (and in some cases SQL databases) on them in order to test our work. 因此,我们的Windows计算机上没有必要的文件(在某些情况下为SQL数据库)来测试我们的工作。 Also if we put the files on, the directories in the scripts will need to be changed every single time to accommodate for this? 另外,如果我们放置文件,脚本中的目录是否需要每次都进行更改以适应这种情况?

Has anyone got any experience with doing a similar thing, or can point me in the right direction? 有没有人有做类似事情的经验,或者可以指出正确的方向? Thanks 谢谢

You are asking a lot of things. 你在问很多事情。 I will try to point you in the "right" direction 我会尝试指出您的“正确”方向

You definitely want each developer to clone the repo on their local machine. 您绝对希望每个开发人员都能在其本地计算机上克隆存储库。

In fact, the main repository usually is bare , which means that contains only the git objects and not a checked out copy, so that you can not even view or edit files on the main repository. 实际上,主存储库通常是bare ,这意味着它仅包含git对象,而不包含检出的副本,因此您甚至无法查看或编辑主存储库上的文件。

It is ok to develop on a windows machine and deploy on a linux server but you need to manage the environment. 可以在Windows计算机上进行开发并在linux服务器上进行部署,但是您需要管理环境。 You can for example have a configuration file for production and a local configuration file, not committed, that each developer adjust for his own machine. 例如,您可以具有用于生产的配置文件和未提交的本地配置文件,每个开发人员都可以针对自己的计算机进行调整。

You can check Chapter 5 - Distributed Git from the Pro Git book for some common distributed workflows. 您可以查看Pro Git手册中的第5章-分布式Git ,了解一些常见的分布式工作流程。

You can save some headaches installing a private github style alternative. 您可以省去安装私有github样式替代项的麻烦。

One last thought: consider one repo per project instead of one repo with multiple projects in it 最后一个想法:每个项目考虑一个仓库,而不是其中包含多个项目的仓库

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

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