Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devops-school/8cafc0c90f000a82c1107d2b6614618f to your computer and use it in GitHub Desktop.
Save devops-school/8cafc0c90f000a82c1107d2b6614618f to your computer and use it in GitHub Desktop.

🧪 GitLab Code Section – Student Lab Manual (v18.0)

Welcome to the GitLab Lab Manual for the Code section. This hands-on guide will walk you through using essential version control and collaboration tools available under a GitLab project’s Code tab.


🎯 Objective

By the end of this lab, you will be able to:

  • Navigate and manage a Git repository using GitLab UI
  • Work with branches, commits, and tags
  • Use merge requests to review and merge changes
  • Visualize repository history and differences
  • Use GitLab snippets and lock files for special file handling

🧱 Prerequisites

  • A GitLab account (GitLab.com or self-managed instance)
  • A sample GitLab project (or fork an existing public one)
  • Git installed (for optional local work)

1️⃣ Repository

Explore the main repository view

  • Go to your project → Code → Repository
  • Browse the file structure
  • Click files to view content
  • Try editing a file via the Web IDE

2️⃣ Branches

Create and switch between branches

  1. Navigate to Code → Branches
  2. Click New branch
  3. Name it feature-xyz
  4. You can now switch to this branch from the dropdown on the file view
  5. Make changes to files in this branch

3️⃣ Commits

Track project history

  1. Go to Code → Commits
  2. View a list of all commits
  3. Click any commit hash to view its details
  4. Use the Compare tab to see changes between commits

4️⃣ Tags

Mark release points

  1. Go to Code → Tags
  2. Click New Tag
  3. Tag your latest commit as v1.0.0
  4. Use tags in CI/CD and release pages

5️⃣ Merge Requests

Merge changes from feature branch to main

  1. Go to Code → Merge Requests → New Merge Request
  2. Select feature-xyz into main
  3. Add a title, description
  4. Assign to reviewer
  5. Submit and discuss changes in comments
  6. Approve and merge once complete

6️⃣ Repository Graph

Visualize branch and merge activity

  • Navigate to Code → Repository Graph
  • This will show branching and merge paths
  • Useful to understand team workflows and commit timelines

7️⃣ Compare Revisions

Compare branches or tags

  1. Go to Code → Compare Revisions
  2. Choose main vs feature-xyz
  3. View all file diffs and commit list

8️⃣ Snippets

Share reusable code snippets

  1. Go to Code → Snippets
  2. Click New Snippet
  3. Paste your code (e.g., sample shell script)
  4. Set visibility (private/internal/public)
  5. Save and share the link

9️⃣ Locked Files

Prevent edits to non-mergeable files

  1. Navigate to Code → Locked Files
  2. Click “Lock a file”
  3. Choose a binary/design file (e.g., logo.psd)
  4. Only you can now edit this file until unlocked

✅ Bonus Tips

  • Use /label, /assign, and /estimate in merge request comments
  • Clone project locally and push commits using Git
  • Use .gitlab-ci.yml to add CI pipelines

🧪 Conclusion

You've now explored all the tools under GitLab's Code tab. These features are essential for working collaboratively, tracking project evolution, and managing source code efficiently.

Happy coding! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment