Pastebins

GitLab Snippets

GitLab's built-in code sharing feature. Personal or project snippets with up to 10 files, Git-backed version history and public or private visibility.

  • Git versioning
  • Multiple files
  • Private snippets
  • API

About GitLab Snippets

Snippets are GitLab's equivalent of a pastebin, built into GitLab.com and self-managed GitLab installations. They are intended for sharing pieces of code, configuration or text that do not need a full repository.

There are two kinds. Personal snippets are not tied to any project and can be public or private. Project snippets live inside a project and follow that project's permissions, so a public snippet in a private project is still only visible to members. On GitLab.com, the Internal visibility level is disabled for new snippets.

Each snippet can hold up to 10 files and is backed by its own Git repository, so every saved edit is recorded as a commit and you can clone the snippet like any other repository. The default maximum snippet size is 50 MB, and administrators of self-managed instances can change snippet settings.

How to create a paste

  1. Sign in to GitLab.
  2. For a personal snippet, select Create new (the plus icon) and then New snippet. For a project snippet, go to the project, select Create new and then New snippet under "In this project".
  3. Enter a title, an optional description, and one or more files. The filename extension sets the syntax highlighting.
  4. Choose the visibility level and create the snippet.

Snippets can also be created and managed through the REST API.

Things to know

  • Visibility: public snippets can be read without an account; private ones need you to be signed in with access. Snippets are not end-to-end encrypted.
  • Project rules apply: a project snippet can never be more visible than its project.
  • Git limits: snippet repositories have a single default branch, and you cannot create branches or use tags or Git LFS.
  • Storage: versioned snippets count towards your namespace's storage, so large files and long histories use up quota.
  • Larger collections: for more than 10 files, GitLab suggests using a wiki instead.

Frequently asked questions

What is the difference between personal and project snippets?

Personal snippets are independent of any project and can be public or private. Project snippets belong to a project and are visible either publicly or to project members only, and the project's own visibility overrides the snippet's setting.

Can anyone see my GitLab snippet?

Public personal snippets can be viewed without signing in. Private personal snippets are visible only to you, and snippets in a private project are visible only to that project's members.

Are GitLab snippets version controlled?

Yes. Each snippet has its own Git repository with a single default branch, and every saved change becomes a commit. Branches, tags and Git LFS are not supported.

Sources

  1. docs.gitlab.com/user/snippets
  2. docs.gitlab.com/api/snippets