<commit_before>---
title: One-Command Deployment
---

Hexo provides a fast and easy deployment strategy. You only need one single command to deploy your site to your servers.

```bash
$ hexo deploy
```

Before your first deployment, you will have to modify some settings in `_config.yml`. A valid deployment setting must have a `type` field. For example:

```yaml
deploy:
  type: git
```

You can use multiple deployers. Hexo will execute each deployer in order.

```yaml
deploy:
- type: git
  repo:
- type: heroku
  repo:
```

## Git

1. Install [hexo-deployer-git].

```bash
$ npm install hexo-deployer-git --save
```

2. Edit **\_config.yml** (with example values shown below as comments):

```yaml
deploy:
  type: git
  repo: <repository url> #https://bitbucket.org/JohnSmith/johnsmith.bitbucket.io
  branch: [branch] #published
  message: [message] #leave this blank
```

| Option    | Description                                                                                                 |
| --------- | ----------------------------------------------------------------------------------------------------------- |
| `repo`    | GitHub/Bitbucket/Coding/GitLab repository URL                                                               |
| `branch`  | Branch name. The deployer will detect the branch automatically if you are using GitHub or GitCafe.          |
| `message` | Customize commit message (Default to `Site updated: {% raw %}{{ now('YYYY-MM-DD HH:mm:ss') }}{% endraw %}`) |

3. Upload your site: `./node_modules/.bin/hexo clean && ./node_modules/.bin/hexo deploy` (or `hexo clean && hexo deploy` if you installed Hexo globally).
4. On Github/BitBucket/Gitlab go to your repository settings and change your main branch from `master` to `published` (or whatever you called it in your \_config.yml). Now your site will show as your account's homepage.

### How does it work exactly?

Your repository will have a **master** branch when you first made it. Keep working on this branch to create your site. When you deploy Hexo will create, or update, a new branch on the remote site (called **published** in the config above). Deployment won't create a new branch locally, nor will it mess with your existing source code in the master branch locally or on the remote. You still need to keep pushing commits to the master branch manually to the remote server to keep your site backed up. In addition, if you are using a CNAME file to customize your Github Pages domain name, you need to put the CNAME file under `source_dir` so that Hexo can push it to the published branch.
<commit_msg>docs(deploy): token config of hexo-deployer-git (#1212)<commit_after>---
title: One-Command Deployment
---

Hexo provides a fast and easy deployment strategy. You only need one single command to deploy your site to your server.

```bash
$ hexo deploy
```

Install the necessary plugin(s) that is compatible with the deployment method provided by your server/repository.

Deployment is usually configured through **\_config.yml**. A valid configuration must have the `type` field. For example:

```yaml
deploy:
  type: git
```

You can use multiple deployers. Hexo will execute each deployer in order.

```yaml
deploy:
- type: git
  repo:
- type: heroku
  repo:
```

Refer to the [Plugins](https://hexo.io/plugins/) list for more deployment plugins.

## Git

1. Install [hexo-deployer-git].

```bash
$ npm install hexo-deployer-git --save
```

2. Edit **\_config.yml** (with example values shown below as comments):

```yaml
deploy:
  type: git
  repo: <repository url> #https://bitbucket.org/JohnSmith/johnsmith.bitbucket.io
  branch: [branch] #published
  message: [message] #leave this blank
```

| Option    | Description | Default
| --------- | --- |
| `repo`    | URL of the target repository |
| `branch`  | Branch name. | `gh-pages` (GitHub)<br>`coding-pages` (Coding.net)<br>`master` (others)
| `message` | Customize commit message. Defaults to `Site updated: {% raw %}{{ now('YYYY-MM-DD HH:mm:ss') }}{% endraw %}` |
| `token`   | Optional token value to authenticate with the repo. Prefix with `$` to read token from environment variable |

3. Deploy your site `hexo clean && hexo deploy`.
  - You will be prompted with username and password of the target repository, unless you authenticate with a token or ssh key.
  - hexo-deployer-git does not store your username and password. Use [git-credential-cache](https://git-scm.com/docs/git-credential-cache) to store them temporarily.
4. Navigate to your repository settings and change the "Pages" branch to `gh-pages` (or the branch specified in your config). The deployed site should be live on the link shown on the "Pages" setting.

{'fraction_non_alphanumeric': 0.12819420783645655, 'fraction_numerical': 0.002555366269165247, 'mean_word_length': 3.0111016225448335, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '394763', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1256, 'n_words': 581}