Snippets help you share code segments or files with yourself, your team, or the world. One more way we're making code collaboration better for professional software teams.


  • Are built for team collaboration or individual sharing.
  • Are syntax sensitive, making drag and drop quick and simple.
  • Are built on Git or Mercurial so revisions are tracked and you can clone and push. 
  • Support multiple files, each snippet can have many files so you can share a single snippet without loosing context.
  • Have amazing API support so you can build snippets into your app or process.

This page

Related pages

  • Teams
    Learn all the basics of Bitbucket teams.
  • snippets Endpoint
    The API for snippets allow you to build upon snippets.

Snippets at a glance

Snippets are as simple as:

  1. Click + in the global sidebar and select Snippet under Create a new.
  2. Paste some code or drag a file onto the page.
  3. Select the owner of the snippet from Create in menu.

    Once you save the snippet for the first time you can no longer change which team or user owns the snippet.

    If you want to let others contribute to a snippet you'll need to make a team the owner. 

  4. Set the permissions to either public or private.

  5. Click Create snippet.

Permissions in snippets

Here's how permissions work for snippets:

Snippet ownerSettingWho can viewWho can edit
TeamPublicAnyone can view the snippet.

Any member of the team can edit the snippet.

To allow a new person to contribute to snippets you can add them to your team.

PrivateOnly team members can view the snippet.
Individual accountPublicAnyone can view the snippet.Only the owner of an individual snippet can edit the snippet.
PrivateOnly you can view the snippet.

Cloning snippets

Clone your snippet so you can work on it locally and push back up to Bitbucket Cloud. 

  1. Select Snippets from the left nav menu.
  2. Select the title of the 'snippet' you want to clone. 
  3. Click the Clone button in the upper-right corner of the Snippets page.
  4. Switch to the directory where you want to clone the snippet using the cd (change directory) command as shown in the following example:

    cd path/to/directory
  5. Paste the clone link into your terminal.

  6. Start working on your snippet. 

You cannot push branches for your snippet. Once you've cloned the snippet to your local system you can use branching locally but must always merge into master before pushing changes. Trying to push a branch other than master will fail.

Last modified on Nov 6, 2018

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.