Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ShahedPHP's avatar

Git

Majority of the websites I make uses Laravel, NGINX, MySQL.

I have just dived into learning how to use Docker. As time goes on my knowledge and experience will definitely improve. So, now I want to use Git (Gitlab) to push my files to my server. Should I initialise Git in my local environment? Or within the Docker?

I’d really like to manage and deploy my websites in an efficient way. I was researching but there isn’t much out there on this topic. So if you know where I am getting at and you can pitch in please elaborate

For an instance I’d have two branches

Release: Code for live site

Staging: Code for dev site

Whenever, I am working on something on my site e.g a new login. I’d create a new branch called login. From there I’d commit and note each push. Whenever, I am complete I’d merge the branch with the Staging. After that I’d tag the Staging branch with eg. V1.2.4 and push tag to the Release branch. When the Release branch is updated it will automatically update the live server files.

I’ve seen someone else’s work and this is how they manage it I believe however, remembering all of it was hard.

I’d like to have something like this but setting it up and having a better understanding is what I need.

Please let me know your thoughts or an efficient way of pushing my work to my server.

0 likes
3 replies
Sinnbeck's avatar

Take it one step at a time. First of you need to learn git. You use it outside of docker to manage your files and branches. Your idea is correct, but while learning I would suggest you make it a bit more simple for yourself. Make a main/master branch for production and learn how to make branches, and how to merge them back into main/master. Once you have a very solid understanding of how this works (handling merge failures etc), you can start learning deployment strategies like the one you mentioned. But take it as a 2 step process (or more) as having to learn git as well as deployment (CI) at the same time will be too much

1 like
ShahedPHP's avatar

Ive started using Git 3 years ago but with my own research and understanding. I have initialised Git on a dev environment and live environment and merged branches and releasing tags pushing pulling fetching etc but this was me all figuring it out myself so I’d say I had a bit of experience. But now I want to understand everything on a better detail

ShahedPHP's avatar

So, I’ve initialised Git in my local environment. I have two branches main & develop

main is protected develop is protected

I played around for a bit on the develop and commit and push on to Gitlab.

I’ve merged develop to main to update the files.

Now that I want to auto deploy to my website what will be the best way to go about this? Auto deploy when there’s a merge or when creating a tag? How will you do it and how do you create such scripts?

Also, when there’s a fix and I need to update it right away do I edit the main branch directly? I believe its called hot fix's or hot points. I’d like to have an basic understanding of of it all and the best ways

What tips do you have for me to be more efficient?

Please or to participate in this conversation.