Organization of work through Git
Rus
Eng
Организация работы через Git

All English-language materials have been translated fully automatically using the Google service

How to add site files to a gitlab project via phpstorm

  • 1. We activate git on the project via VCS -> Enable Version Control Intergration
  • 2. Add a binding to the project on gitlab via VCS -> Git -> Remotes . Click on + and add a link to the project in the format https://gitlab.com/USERNAME/PROGECTNAME.git
  • 3. After adding the link, we will log in to the gitlab, if not logged in yet
  • 4. Add the .gitignore file and comment out unnecessary files and folders, for example:
  • /bitrix/
    /!doc/
    /test/
    /upload/
    /vendor/
    /.idea/
  • 5. We mark all the necessary files and folders with Ctrl + A
  • 6. We make a commit, and then push to the server. After completion, all files and folders you have selected will be on the server
  • 7. Instead of points 1 and 2, you can immediately use the command VCS -> Get from Version Control

How to logically organize work with the site through Git

  • 1. Create a master branch master and a testing branch dev .
  • 2. When a new task appears, a branch for the task is created from the updated branch master
  • 3. The task is executed and merged into the dev branch, all conflicts are resolved and the functionality is checked (locally)
  • 4. The dev branch is uploaded to the dev server, the operability is checked
  • 5. If all is well, the task branch is merged with the updated master branch, all conflicts are resolved and the operability is checked (locally)
  • 6. The master branch is uploaded to the production server

In console commands, it looks like this:

1. git checkout master
2. git pull
3. git checkout -b task-branch
* task in progress *
4. git checkout dev
5. git pull
6. git merge task-branch
* conflicts are resolved *
7. git push
* checking the performance on dev *
8. git checkout master
9. git pull
10. git merge task-branch
* conflicts are resolved *
11. git push

Automatic uploading of files to the server after commit using .gitlab-ci.yml

Place the file at the root of the project. Replace the constants with your own and define them in the project settings, write the paths, and place the code in the file itself:

deploy:
  before_script:
    - apt-get update -y
    - apt-get install -y rsync sshpass
    # Pass the password from the environment variable
    - export SSHPASS=$SSH_PROJECT_PSWD
  script:
    # sync (push rsync)
    - rsync --recursive --links --owner --group --times --verbose --no-perms --chmod=D0700,F0700 --rsh="sshpass -e ssh -o StrictHostKeyChecking=no" --exclude '.git' --exclude '.gitlab-ci.yml' -avz ./ $SSH_PROJECT_USER@$SSH_PROJECT_SERVER:/ПОЛНЫЙ_РУТ_ПУТЬ_К_ФАЙЛАМ_ВАШЕГО_ПРОЕКТА_НА_СЕРВЕРЕ/
  only:
    - master

This code will upload files and folders under the root owner. If you need to set a custom owner, then the last line should be modified to:

- rsync --recursive --links --times --verbose --chmod=D0700,F0700 --chown=bitrix:bitrix --rsh="sshpass -e ssh -o StrictHostKeyChecking=no" --exclude '.git' --exclude '.gitlab-ci.yml' -avz ./ $SSH_PROJECT_USER@$SSH_PROJECT_SERVER:/ПОЛНЫЙ_РУТ_ПУТЬ_К_ФАЙЛАМ_ВАШЕГО_ПРОЕКТА_НА_СЕРВЕРЕ/

If you are using a non-standard port, the command should be modified by adding ssh -p PORT_NUMBER, like so:

- rsync --recursive --links --times --verbose --chmod=D0700,F0700 --chown=bitrix:bitrix --rsh="sshpass -e ssh -p 7777 -o StrictHostKeyChecking=no" --exclude '.git' --exclude '.gitlab-ci.yml' -avz ./ $SSH_PROJECT_USER@$SSH_PROJECT_SERVER:/ПОЛНЫЙ_РУТ_ПУТЬ_К_ФАЙЛАМ_ВАШЕГО_ПРОЕКТА_НА_СЕРВЕРЕ/

To install rsync on the server, use the command:

yum install rsync

This code is not a panacea and is suitable only for a small project, since it does not delete files, does not allow individual commits to be uploaded to the server, after each commit it makes a complete upload of files to the server

If you have a better solution, please share it.

Uploading local repository to gitlab project via console

Initializing git

git init
git add
git commit -m "Первый коммит"

Link a local repository to a gitlab repository

git remote add origin https://gitlab.com/USERNAME/PROGECTNAME.git

Uploading files to gitlab

git push origin master

Comments

There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment

Send

FEEDBACK

Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully

Phones

+7(993) 007-18-96

Email

info@tichiy.ru

Address

Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number