Skip to main content

Writing Markdown for documents and commits

When you're writing commit messages or documents to be shared in a remote repository (such as the very documents in this workshop's repository), you can use Markdown syntax for their structure.

Markdown is a simple language that allows for some formatting.

Many tools other than Git also use Markdown, so now is as good a time as any to learn about it!

Markdown blocks

You can add a title line in a Markdown document (but these are seldom used in commit messages):

# Biggest title

## Second biggest

### Third biggest

#### Fourth biggest

##### Fifth biggest

###### Sixth biggest

I use # and ## often, and sometimes ###.

You can add a code block, which can be useful to display some segment of your code (e.g. for explanations or comments). Use three backticks at the start and at the end of your block:

```
Your code block would go here.
You can make it multiple lines.
```

::: tip If you need to write a set of backticks like this within a codeblock, just add an extra backtick to the outer set.

````
```
The outer block of four backticks allow us to
put three backticks within the codeblock
```
````

The output would look like this:

```
The outer block of four backticks allow us to
put three backticks within the codeblock
```

:::

You can add blockquotes, although I almost never use these when working with Git:

> This is a block quote

It looks like this.

You can add lists (numbered or bulleted):

1. First item
2. Second item
3. Third item

- Bullet one
- Bullet two
- Bullet three

Inline markdown

While inside a paragraph, you can surround words with * or ** to make them italic or bold:

This is _italic_. This is **bold**.

You can make certain words into code by surrounding them with a backtick:

This is `code`.

You can include links by surrounding the linked text with square brackets, and placing the link immediately after inside normal brackets:

[This is a link](https://git-workshop.tecladocode.com)