S
S
Stanislav2015-09-22 15:07:13
git
Stanislav, 2015-09-22 15:07:13

How to change the folder address of a repository and its working folder in git?

So it turns out that for some projects, the most optimal deployment solution will not be using some specialized deployment tools like capistrano, but using the capabilities of git itself. For example, when there is no reasonable possibility to move all user and other statics/logs/etc outside the directory updated at the time of the next deployment - this happens if the project is some kind of site on cms that does not have sufficient configuration tools for this, then there is time to rework the code and the costs associated with this will not pay off in the end.
In this case, the deployment can be carried out, for example, in this way, in my opinion:
There is a local repository(ies) in which development is carried out. It has a test branch and a production branch, for example. It also added a remote bare repository somewhere on the server to which these two branches are uploaded. For example, other users can work with this remote repository, or you can take the code from there yourself, being on your other working machine. Each developer who is connected to this remote repository has their own test local server.
And there is a test and working server somewhere on the network. Deployment from a test repository to a test or production server is supposed to be done by connecting repositories on these servers to it. And this is where my question lies.
The procedure for connecting repositories, in my opinion, should be as follows:
A regular repository is initialized, that remote bare repository is cloned into it, or rather the test branch or the production branch. This happens successfully, but here's the problem - the folders where the files of these repositories should go may differ.
That is, for example, for a local repository where everyone is developing, the repository folder can be called site.com. When this repository is copied to bare, it doesn't matter what this folder will be called - it is not created there. When this remote repository is copied on other machines or by other developers, this is also not a problem - the folder is created exactly the same, site.com, and the local copy of the repository basically does not care what it will be called.
But when it comes to clones of a repository on a test or production server, the fact that inside the cloned repository starts to look like:

.git
site.com

is no longer satisfied, since, for example, the DocumentRoot for these servers may look like in the case of a test test.site-company.com, and in the case of a worker, already site.com or whatever else, for example www.site.com.
If there was only one server where the deployment is carried out, then there would be no problem - just the developers on their local machines would have the turnip folder named exactly the same as on the working / test server. But when there are two servers, then it is necessary to change the working directory of the repository in one of the cases at least, but better - in both.
And here I have a problem - as far as I understand, this is done by a command in the root of the turnip of the test / working server like
git --git-dir="blabla" --work-tree="blablabla"
But how exactly it works, I honestly don’t understand and I can’t find intelligible manuals for this. Maybe someone came across this and implemented it in this way or similarly using git to deploy to two different servers with a different directory structure of web servers?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zakharov Alexander, 2015-09-22
@AlexZaharow

1. Romance: Oooh, how familiar! In principle, after mastering grunt, everything became much easier. I had dozens of plugins in my project. Now everything is going into one min.js.
2. Maybe:
But if you have a problem with developers separating two servers and at some point in time one developer is developing only on one server, then you can use this crutch: edit the file "C:\Windows\ System32\drivers\etc\hosts" and use one link to go to different servers at different stages of development. This is how I work at home sometimes. I raise the server part, and the application thinks that I have it at work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question