简体   繁体   English

使用 Windows 服务器上的中央存储库设置 GIT

[英]Setting up GIT with a central repository on a Windows server

Having done quite some reading on how to set up GIT (also considered other VCS's) I still have trouble figuring out how to do it for my situation.在阅读了很多关于如何设置 GIT(也考虑过其他 VCS)的资料后,我仍然无法弄清楚如何针对我的情况进行设置。

I am single developer, working on multiple projects in Delphi under Windows.我是一名开发人员,在 Windows 下的 Delphi 中处理多个项目。 I have two PC's on which I develop (desktop & laptop) and a Windows 2016 server.我有两台用于开发的 PC(台式机和笔记本电脑)和一台 Windows 2016 服务器。 Ideally I would like to have central repositories on the server and then push/pull from/to either development PC (as if there are two developers).理想情况下,我希望在服务器上拥有中央存储库,然后从/向任一开发 PC 推送/拉取(就像有两个开发人员一样)。

The purpose of the remote repositories on the server is to have a single location that I can include in my daily backups.服务器上的远程存储库的目的是拥有一个可以包含在我的日常备份中的位置。

I came across this article which appears to be a very simple and straightforward approach.我遇到了这篇文章,它似乎是一种非常简单直接的方法。 However, it still leaves me with some questions:但是,它仍然给我留下了一些问题:

  1. Does this approach still require me to install GIT on the server?这种方法是否仍然需要我在服务器上安装 GIT?
  2. Once all repositories are pushed to the location on the server, would backing up this folder be sufficient to have a full backup of the projects?将所有存储库推送到服务器上的位置后,备份此文件夹是否足以对项目进行完整备份?
  3. Is there a simple way to exclude "unwanted" Delphi files (eg *.dcu) from GIT?有没有一种简单的方法可以从 GIT 中排除“不需要的”Delphi 文件(例如 *.dcu)?
  4. I have a single (top-level) folder, containing a sub-folder for each project.我有一个(顶级)文件夹,其中包含每个项目的子文件夹。 Additionally there are some sub-folders, containing files (Delphi units) shared between projects.此外,还有一些子文件夹,包含项目之间共享的文件(Delphi 单元)。 Should these files be exclude from the project repositories and contained in their own repository?这些文件是否应该从项目存储库中排除并包含在它们自己的存储库中? Is there a recommended approach?有推荐的方法吗?

Hopefully it's acceptable to have multiple (related) questions in a single post.希望在一个帖子中有多个(相关)问题是可以接受的。 Any guidance or links to applicable/useful resources for this setup will be highly appreciated.任何指向此设置的适用/有用资源的指南或链接将不胜感激。

In the link you have provided windows filesharing is used and your central repositories are just folders on a fileshare (eg \\\\server\\repos ).在您提供的链接中,使用了 windows 文件共享,您的中央存储库只是文件共享上的文件夹(例如\\\\server\\repos )。 So it is like working with repos on your local machines.所以这就像在本地机器上使用 repos 一样。 But I do not know how good git and the smb protocol work together.但是不知道git和smb协议配合起来效果如何。 You may run into problems on simultaneous access to a repo.您可能会在同时访问存储库时遇到问题。

  1. ... install GIT on the server ? ...在服务器上安装 GIT No.不。

You can create your bare repositories on the server simply by doing the following from one of your clients in a git-bash (assuming your share on the server is called repos ).您可以通过在 git-bash 中从您的客户端之一执行以下操作,在服务器上创建您的裸存储库(假设您在服务器上的共享称为repos )。

$ cd //server/repos
$ mkdir ProjA.git
$ cd ProjA.git 
$ git --bare init

It is by convention that a bare repository ends with .git .按照惯例,裸仓库以.git结尾。

To prepare a project on your client-machine, create an appropriate .gitignore file (find one on https://github.com/github/gitignore ), start a git-bash and change into the projects root folder要在您的客户端机器上准备一个项目,请创建一个适当的.gitignore文件(在https://github.com/github/gitignore上找到一个),启动一个 git-bash 并切换到项目根文件夹

$ cd /d/Projects/ProjA
$ git init
$ git remote add origin //server/repos/ProjA.git
$ git add .
$ git commit -m "first commit"
$ git push origin master

Now your branch master from project ProjA is pushed to the repo ProjA.git on the server.现在,项目ProjA分支master被推送到服务器上的 repo ProjA.git The branchname master is by convention the default branch in git.按照惯例,分支名称master是 git 中的默认分支。

To clone a repo from the server on one of your clients using a git-bash:要使用 git-bash 从您的一个客户端上的服务器克隆存储库:

$ git clone //server/repos/ProjA.git
  1. ...would backing up this folder be sufficient to have a full backup of the projects? ...备份此文件夹是否足以对项目进行完整备份? Everything stored in the bare repo wil be backed up.存储在裸仓库中的所有内容都将被备份。 But I am not an expert here.但我不是这里的专家。

  2. ... exclude "unwanted" Delphi files? ...排除“不需要的”Delphi 文件? Use .gitignore .使用.gitignore You can find some on https://github.com/github/gitignore .你可以在https://github.com/github/gitignore上找到一些。

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

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