A
A
Alexander Pankov2022-01-28 11:21:03
PHP
Alexander Pankov, 2022-01-28 11:21:03

How to sync with files on vps when changing git branch locally?

Hello, I am developing on a mac 2015
inside the docker
, very poor performance, especially if the database is 2+ GB and a lot of requests,

so I decided to move to remote development,
I bought vps, put the docker
project files and the database was mounted from the vps host system to the docker (volumes)
ports are open and from the browser I have access to the site in the docker

, the same project files are on my laptop, when I edit them phpstorm saves them and uploads them to vps (rsync)
from there they are already seen by the docker and I see changes in the browser

those php-fpm \ nginx \ mysql \ redis \ elasticsearch - everything is spinning in docker and not on my laptop, I only send files to vps, so the speed is better than working natively with docker on a poppy
and there are several projects, each with 10+ gigs, several versions of the database per project - all memory is consumed by both sdd and ram on the laptop

in the current workflow while everything works - it suits, the speed is lower than if php-fpm is set "natively" on a poppy through brew, but still many times higher than inside the "native" docker

ran into a problem - changing branches, merging and working with commits (git)

problem:
I write code, I need a hotfix in another branch and test (manually)
I change my branch ... that's all, dancing with a tambourine for 5 minutes so that similar files end up on the vps and git inside the vps also looked at the branch with the htfix (sometimes changing the branch affects 20-40 files)
tired of constantly coming up with something incomprehensible (mostly manually copying files to the vps or logging in via ssh and changing the git checkout branch inside the vps ... usually 1-2 problem files always come out due to spaces or formatting)

questions:
when do I I change the branch on my laptop - how can I make the branch change on the vps in the same way?
when I commit - how to commit on vps too?

I googled and couldn’t find the info that was understandable for myself
, googled mutagen.io which seems to be keeping track of file changes
but it’s not about the git story, you can certainly screw it up, but it seems to me that I’m reinventing the wheel and there are already good solutions
and I’m wondering if I need can I git on vsp... maybe enough on a laptop

How convenient is it to change git branches while synchronizing with vsp (inside which is a docker, well, I don’t use docker 100% right now, I don’t push to registry, a simple compose with its own instructions, and the code and database are mounted)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2022-01-28
@PankovAlxndr

Why do you need git on vps? There must be some one "source of truth."
It seems to me that the history should be like this: git server (github/gitlab/etc) -> local repository -> rsync to vps -> volume to docker
Accordingly, when you change a branch in the local repository, rsync sees file changes and synchronizes them with vps , which knows nothing about git - for him it's just a collection of files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question