Standard Operations

Git Workflow & Introduction

What is GIT?
Git is a distributed revision control and source code management system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux kernel development. Git is a free software distributed under the terms of the GNU General Public License version 2.
We follow Centralized Git Workflow for our Collaboration Process. Learn more about it
What is GITLAB?
Developed on the basis of Git version control system, is one of the best web platforms for hosting project source codes. Although GitLab is similar to GitHub in terms of functionality, it seems to be a better choice for teamwork than its famous counterpart and GitLab features may be different somewhat.
GitLab exists in two forms. The first one is SAAS - website with open registration, and the second one is an individual solution GitLab Community Edition. They both can be perfectly customized to any service.
GitLab benefits: reasons to use GitLab
Free service. Users can find an unlimited number of private repositories in GitLab. This service is completely free. Nevertheless, there is a notification that users will have to pay for storing files that exceed 10 Gb in their size.
Open source code repository. GitLab software is available under the license with an open source code.
Free hosting. There is a Community Edition - free source code repository for Debian, Ubuntu and CentOS computers. Enterprise Edition is a paid solution that adds proprietary features over Community Edition, improving integration with other online tools, server options management, workflow management as well as authentication and integration with authorization.
Bug tracking mechanism. GitLab has an effective integrated bug tracking mechanism. Users can create tasks, comment and close them.
Files editing in the web interface. Editing of files is possible directly in the web interface and you can do it without loading of the repository. So if you need to make small changes in an open source code websites, this way is that what you need.
Its drawbacks
The interface is rather slow - switching from one page to another takes some time.
Technical problems with repositories are quite frequent.
GIT BASIC COMMANDS
git config --global user.email
Configure the author name and email address to be used with your commits.
git init
git clone “git url of the repo” /path/to/save
Clones the remote repository and save to the directory mentioned in the command
git status
Shows the modified files which are not pushed to the origin/remote
git add .
Adds all changed files for committing to local
git add “filename”
Adds specific file for committing
git commit -m "Commit message"
Saves all file for committing with a headnote for easy identification at local level
git push
Pushes all changes to the remote repository
git pull
Pulls all changes from the remote repository
git fetch
Fetch and Sync all datas from the remote repository
git checkout “branch name”
Checkouts to a specific branch
git branch
Displays branch which i currently working
git reset --hard
To drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it, do this
git stash
Undo all Local changes
git checkout -b ”branch name”
Creates and checkout to the new branch
GIT Workflow
GItlab is our company's centralized repository system. Every project source code should be pushed to concerned repositories.
Following are the branches on each repositories:-
Features/Release Branch (Developer to push and generate merge request)
Development Branch (Leads to review and merge the request)
Staging Branch (Leads to review and merge the request)
Master Branch (Leads to review and merge the request)
Repo member access will be only give to the developers who are working on the specific project.
Stages of Server and Automation
Below are the stages of servers according to the Deployment Strategy and the branches connected in GITLAB:-
Local (C9, LocalByFlywheel)
Staging
Development
Live (Master)
Any code pushed to development and staging branch will be auto-deployed to the concerned servers without any manual triggering.
Currently we are developing in C9 and that will be considered as Local.
Staging Server Link-
Development Server Link:-
Live/Master:-
Below is our architecture followed for the Merging process
Features/Release Branch (Developer to push and generate merge request)
Development Branch (Leads to review and merge the request)
Staging Branch (Leads to review and merge the request)
Master Branch (Leads to review and merge the request)

#SSH Key Generation

SSH key is used for secure authentication between two hosts. This key is encrypted and used for passwordless authentication.
We have private key and public key where public key is used as the primary key for the interaction between hosts.
In Order to grant access to the repositories from gitlab, we have to add our ssh key to gitlab account.
To generate a ssh public key,
For Windows,
Install git and git bash
Open git bash terminal and type the below command
ssh-keygen
cat /the/path/displayed ending with id_rsa.pub/
Copy the ssh key and give to devops team so that they will add you key to the gitlab
For Linux/Mac
Type the below commands:-
ssh-keygen
This will ask you a couple of question which everything can be passed by pressing enter
cat /root/.ssh/id_rsa.pub (linux)
cat /home/user/.ssh/id_rsa.pub (mac)

#Pushing Code to Remote Repository Via Command Line

For every project, Repo will be created by our DevOps team which will consist of the basic .gitignore file for the Wordpress sites.
**1)**Clone the repo and the directory would be the web servers and move everything under the cloned folder to the local webserver path including .git(folder), .gitignore(file).
git clone “git url” /path/to/save
2) Configure your Gitlab ID within the Git folder
git config --global user.email
3) Start developing and changing the codes. After that, do the below commands to push to the remote repo
git checkout development
Checkouts to the branch development which you will need to work. By default it will be master
git add .
Adds all changed files for committing to local
or
git add “filename”
Adds specific file for committing
git commit -m "Commit message"
Saves all file for committing with a headnote for easy identification at local level
git pull
Pulls all changes from the remote repository if any other developers are working on the same repo(avoiding merge conflicts)
git push
Pushes all changes to the remote repository
You can try these commands as well using the below git url which is creates for a test purpose. By default you are added to into teamengineering group and access is granted what you have to do is to clone the repo and start working.
GITURL- :teamarmentum/ip-testscm.git
Follow the below URL to use Docker as LocalbyFlywheel
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.