keeping .git subdirectory with the working files on server

29 views
Skip to first unread message

Yar Dmitriev

unread,
Feb 26, 2015, 10:15:17 PM2/26/15
to capis...@googlegroups.com
Hi

When a specific commit is deployed and runs on a server, I think it is useful to keep .git subdirectory with it.

Why?

1) Having the git repo with the correct HEAD allows to run `git status`, for example, and quickly inspect the working copy for any possible changes or additions. 

2) The other possible use is lightning-fast updates (for simpler cases, where atomicity is not important) using git 2.3's "push to deploy" feature (see https://github.com/blog/1957-git-2-3-has-been-released). The working tree files will be updated automatically.

Can anybody suggest how to achieve this with Capistrano 3, without hacking it too much?

Of course, I know that it is a good practice to always make a proper release, in its own directory. However, there are times when it is vital to fix a production problem very quickly. Or times when you want to preview numerous small updates at a staging server in quick succession.

I tried running `git --git-dir=<my project>/repo --work-tree=<my project>/current status`. Strangely, git shows every file as deleted and untracked in that case.


(Using Capistrano 3.3.5, git 2.3.1.167).

Best regards
---
Yar

troels knak-nielsen

unread,
Feb 27, 2015, 2:32:28 AM2/27/15
to capis...@googlegroups.com
Isn't this covered by :deploy_via, :remote_cache?
--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/88b8f83b-aff9-474b-87da-2f204415808d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lee Hambley

unread,
Feb 28, 2015, 12:11:19 PM2/28/15
to Capistrano
:remote_cache is the new default in cap3. For cap2, that is a valid suggestion.

The logic is safety. We would be negligent if the default was to dump your entire project into your webroot, so for that reason the .git directories are never checked out, in fact we use `git archive` to make sure they never exist on disk.

To avoid this, you can easily patch (using Rake, or Ruby) the git methods to checkout in the way you prefer see:
Reply all
Reply to author
Forward
0 new messages