Experiment No. 3
Title: Implement GitLab Operations using Git.
The objective of this experiment is to guide you through the process of using Git commands to interact with GitLab, from creating a repository to collaborating with others through merge requests.
GitLab is a web-based platform that offers a complete DevOps lifecycle toolset, including version control, continuous integration/continuous deployment (CI/CD), project management, code review, and collaboration features. It provides a centralized place for software development teams to work together efficiently and manage the entire development process in a single platform.
Key Features of GitLab:
Version Control: GitLab provides version control capabilities using Git, allowing developers to track changes to source code over time. This enables collaboration, change tracking, and code history maintenance.
Repositories: Repositories on GitLab are collections of files, code, documentation, and assets related to a project. Each repository can have multiple branches and tags, allowing developers to work on different features simultaneously.
Continuous Integration/Continuous Deployment (CI/CD): GitLab offers robust CI/CD capabilities. It automates the building, testing, and deployment of code changes, ensuring that software is delivered rapidly and reliably.
Merge Requests: Merge requests in GitLab are similar to pull requests in other platforms. They enable developers to propose code changes, collaborate, and get code reviewed before merging it into the main codebase.
Issues and Project Management: GitLab includes tools for managing project tasks, bugs, and enhancements. Issues can be assigned, labeled, and tracked, while project boards help visualize and manage work.
Container Registry: GitLab includes a container registry that allows users to store and manage Docker images for applications.
Code Review and Collaboration: Built-in code review tools facilitate collaboration among team members. Inline comments, code discussions, and code snippets are integral parts of this process.
Wiki and Documentation: GitLab provides a space for creating project wikis and documentation, ensuring that project information is easily accessible and well-documented.
Security and Compliance: GitLab offers security scanning, code analysis, and compliance features to help identify and address security vulnerabilities and ensure code meets compliance standards.
GitLab Pages: Similar to GitHub Pages, GitLab Pages lets users publish static websites directly from a GitLab repository.
Benefits of Using GitLab:
End-to-End DevOps: GitLab offers an integrated platform for the entire software development and delivery process, from code writing to deployment.
Simplicity: GitLab provides a unified interface for version control, CI/CD, and project management, reducing the need to use multiple tools.
Customizability: GitLab can be self-hosted on-premises or used through GitLab's cloud service. This flexibility allows organizations to choose the hosting option that best suits their needs.
Security: GitLab places a strong emphasis on security, with features like role-based access control (RBAC), security scanning, and compliance checks.
Open Source and Enterprise Versions: GitLab offers both a free, open-source Community Edition and a paid, feature-rich Enterprise Edition, making it suitable for individual developers and large enterprises alike.
Computer with Git installed (https://git-scm.com/downloads)
GitLab account (https://gitlab.com/)
Step 1: Creating a Repository
Sign in to your GitLab account.
Click the "New" button to create a new project.
Choose a project name, visibility level (public, private), and other settings.
Click "Create project."
Step 2: Cloning a Repository
Open your terminal or command prompt.
Navigate to the directory where you want to clone the repository.
Copy the repository URL from GitLab.
Run the following command:
git clone <repository_url>
Replace <repository_url> with the URL you copied from GitLab.
This will clone the repository to your local machine.
Step 3: Making Changes and Creating a Branch
Navigate into the cloned repository:
Create a new text file named "example.txt" using a text editor.
Add some content to the "example.txt" file.
Save the file and return to the command line.
Check the status of the repository:
Stage the changes for commit:
git add example.txt
Commit the changes with a descriptive message:
git commit -m "Add content to example.txt"
Create a new branch named "feature":
git branch feature
Switch to the "feature" branch:
git checkout feature
Step 4: Pushing Changes to GitLab
Add Repository URL in a variable
git remote add origin <repository_url>
Replace <repository_url> with the URL you copied from GitLab.
Push the "feature" branch to GitLab:
git push origin feature
Check your GitLab repository to confirm that the new branch "feature" is available.
Step 5: Collaborating through Merge Requests
Create a merge request on GitLab:
Go to the repository on GitLab.
Click on "Merge Requests" and then "New Merge Request."
Choose the source branch ("feature") and the target branch ("main" or "master").
Review the changes and click "Submit merge request."
Review and merge the merge request:
Add a title and description for the merge request.
Assign reviewers if needed.
Once the merge request is approved, merge it into the target branch.
Step 6: Syncing Changes
After the merge request is merged, update your local repository:
git checkout main
git pull origin main
This experiment provided you with practical experience in performing GitLab operations using Git commands. You learned how to create repositories, clone them to your local machine, make changes, create branches, push changes to GitLab, collaborate through merge requests, and synchronise changes with remote repositories. These skills are crucial for effective collaboration and version control in software development projects using GitLab and Git.
What is GitLab, and how does it differ from other version control platforms?
Explain the significance of a GitLab repository. What can a repository contain?
What is a merge request in GitLab? How does it facilitate the code review process?
Describe the steps involved in creating and submitting a merge request on GitLab.
What are GitLab issues, and how are they used in project management?
Explain the concept of a GitLab project board and its purpose in organising tasks.
How does GitLab address security concerns in software development? Mention some security-related features.
Describe the role of compliance checks in GitLab and how they contribute to maintaining software quality.