DEV Community

Pranav Bakare
Pranav Bakare

Posted on

Getting Started with GitLab

Getting Started with GitLab

GitLab is a DevOps platform that provides version control, CI/CD pipelines, and collaborative tools for software development. Here's an overview of important terminologies and a practical example to help you get started.


Important GitLab Terminologies

  1. Repository (Repo): A project folder where your codebase is stored.

Example: A repository named my-app contains your application's source code.

  1. Branch: A parallel version of your project.

Default branch: main or master.

Example: feature-login branch for working on the login feature.

  1. Merge Request (MR): A request to merge changes from one branch to another.

Example: Merge the feature-login branch into main.

  1. Pipeline: A set of automated steps for building, testing, and deploying code.

Example: CI/CD pipelines.

  1. Runner: A GitLab agent that executes CI/CD jobs.

Example: Shared runners hosted by GitLab.

  1. Jobs: Tasks defined in a pipeline.

Example: Running unit tests or deploying an application.

  1. Artifacts: Files generated by jobs that can be downloaded or passed to subsequent jobs.

Example: Test reports.

  1. Tags: Mark specific points in history.

Example: v1.0.0 tag for the first release version.

  1. Groups: Organize projects and manage permissions.

Example: A team-backend group containing all backend repositories.

  1. Issues: Track bugs, enhancements, or tasks in your project.

Example: Create an issue to fix a bug.


Setting Up GitLab

  1. Create an Account:

Sign up at GitLab.

  1. Create a New Project:

Go to Projects → New Project → Choose a blank project.

Give it a name, e.g., my-app.

  1. Clone the Repository:

git clone https://gitlab.com//my-app.git

  1. Add Files and Push:

cd my-app
echo "# My App" > README.md
git add README.md
git commit -m "Initial commit"
git push origin main


Example GitLab Workflow

Step 1: Create a Feature Branch

git checkout -b feature-login

Make changes to your code and commit:

git add .
git commit -m "Added login feature"
git push origin feature-login

Step 2: Open a Merge Request

Navigate to your project in GitLab.

Go to Merge Requests → New Merge Request.

Select feature-login as the source branch and main as the target branch.

Submit the merge request.


CI/CD Pipeline Example

  1. Create a .gitlab-ci.yml File: This file defines the CI/CD pipeline.

stages:

  • build
  • test
  • deploy

build-job:
stage: build
script:
- echo "Building the application..."

test-job:
stage: test
script:
- echo "Running tests..."

deploy-job:
stage: deploy
script:
- echo "Deploying the application..."

  1. Push the File to GitLab:

git add .gitlab-ci.yml
git commit -m "Added CI/CD pipeline"
git push origin main

  1. View Pipeline:

Go to CI/CD → Pipelines to monitor pipeline execution.


Summary

GitLab simplifies collaboration and automation in development workflows. By understanding key terminologies and practicing with simple examples like branch creation, merge requests, and CI/CD pipelines, you can effectively utilize GitLab in your projects.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay