Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

Git Snippets allows you to include pieces of code from your Git repository into Confluence pages.

On this page:

Table of Contents

Bitbucket Server Requirements

Git Snippets requires an Application Link in order work with Bitbucket Server. Go to the Confluence Administration → Application Links an follow the Documentation to create an Application Link to Bitbucket. After that, the users will get an one-time authorization message when they want to see or add a Git snippet if they haven't authorized Bitbucket yet.

Bitbucket Cloud Requirements

No additional steps are required to use public repositories from Only public repositories are supported at the moment.

For private repositories you need to add a Bitbucket username and app password. Log in to and go to Settings → App Passwords. Create a new password and check the Read permission for repositories.

Image Added

Copy the generated password and go to Confluence Administration → Git Snippets Settings and insert your username and app password in the section.

Image Added

Github requirements

In order for Git Snippets to work with Github, you need a Github account with which the Git Snippets macro will make the requests to get the code from Github. Git Snippets will need a personal access token, you can create with your Github account. Then go to Confluence Administration → Git Snippets Settings and insert your token.

Git snippet macro

With the Git snippet macro, you can insert code from Bitbucket Server or Github into a Confluence page.

Inserting a snippet

To add a snippet, browse to a file in the web frontend of Bitbucket Server or Github, select the lines you want to display in Confluence (if you don't select the lines, the whole file will be displayed) and copy the URL.

Then go to a Confluence page, add the Git snippet macro and paste the URL you just copied.

You should now see the selected code as a snippet in the macro preview. Click Save to insert the macro.

Updating the line numbers

The line numbers will be extracted automatically from the URL, but you can change them afterwards at any time.

Updating the commit hash

The commit hash is automatically inserted when you paste an URL. When the code changes in the repository, the commit hash will differ from the one stored in the macro and Git snippets will try to show the correct snippet. even though the line numbers might have changed. You can update to the latest commit  by clicking Load latest commit.

Git snippet guide blueprint

With the Git snippet guide blueprint, you can create step-by-step guides with Git snippet macros.

For example, you can use real code to document how to create a Confluence macro by pointing out the necessary steps like updatinh the plugin XML, creating a class, etc.

Download Git Snippets for Confluence
from the Atlassian Marketplace and
try it for free!