简体   繁体   中英

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.

I am single developer, working on multiple projects in Delphi under Windows. I have two PC's on which I develop (desktop & laptop) and a Windows 2016 server. 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).

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?
  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?
  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. 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 ). So it is like working with repos on your local machines. But I do not know how good git and the smb protocol work together. You may run into problems on simultaneous access to a repo.

  1. ... install GIT on the server ? 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 ).

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

It is by convention that a bare repository ends with .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

$ 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. The branchname master is by convention the default branch in git.

To clone a repo from the server on one of your clients using a 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? Use .gitignore . You can find some on https://github.com/github/gitignore .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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