R
R
Rail Khamdeev2014-08-17 11:47:34
git
Rail Khamdeev, 2014-08-17 11:47:34

How to properly deploy applications with Git?

Good day to all!
At the moment, I use a very simple deployment option when the post-receive hook is triggered on the server and git checkout -f branchname is done in it.
Everything suits me, but here's the problem. If I create a file in the project, then when I deploy it, it appears on the site, but if I do git rm filename in the project, the deployment goes through, but the file remains on the server (which is logical, because we stupidly expand the current branch into a directory). So the question is - how to properly implement a deployment so that all files controlled by the version control system are added and deleted, but directories that are not under the control of the system remain on the server (for example, the /upload directory)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rail Khamdeev, 2014-08-18
@rhamdeew

And thank you everyone!
I resolved the issue myself.
So the scheme is now as follows - when pushing to a remote server in the post-receive hook, here is the code

#!/bin/sh
git --git-dir ~/test/.git --work-tree ~/test/ pull

True, at first I had to clone the repository for the first time in ~ / test, but now everything works

A
andymitrich, 2014-08-17
@andymitrich

Deploy everything in the same master branch, for example.

K
Kir, 2014-08-17
@angry_bender

Check out the new release. and the file is to hell with it, if it is not used, it will not be included, what difference does it make whether it is physically there or not

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question