Linux command
gh-pages 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Deploy dist folder to gh-pages
npx gh-pages -d [dist]
Deploy with custom message
npx gh-pages -d [dist] -m "[Deploy to GitHub Pages]"
Deploy to custom branch
npx gh-pages -d [dist] -b [docs]
Deploy specific files
npx gh-pages -d [dist] -s "[*.html,*.css]"
Deploy with custom remote
npx gh-pages -d [dist] -o [upstream]
Deploy with a custom domain (CNAME)
npx gh-pages -d [dist] --cname [example.com]
说明
gh-pages is an npm package that publishes files to a GitHub Pages branch. It automates pushing built static sites to the gh-pages branch for hosting, creating clean commits of your distribution folder to the target branch. The tool makes deployment a single command and is commonly used in CI/CD pipelines and as a package.json script.
参数
- -d, --dist _dir_
- Directory to deploy.
- -s, --src _pattern_
- File pattern within dist.
- -b, --branch _branch_
- Target branch (default: gh-pages).
- -o, --remote _remote_
- Remote name (default: origin).
- -m, --message _msg_
- Commit message.
- -u, --user _name_
- Git user name.
- -e, --email _email_
- Git user email.
- -a, --add
- Add files, don't remove existing.
- -t, --dotfiles
- Include dotfiles.
- -r, --repo _url_
- Repository URL to push to (if not in a git repo or pushing elsewhere).
- --cname _domain_
- Create a CNAME file with a custom domain name.
- --nojekyll
- Add .nojekyll file to bypass Jekyll processing on GitHub Pages.
FAQ
What is the gh-pages command used for?
gh-pages is an npm package that publishes files to a GitHub Pages branch. It automates pushing built static sites to the gh-pages branch for hosting, creating clean commits of your distribution folder to the target branch. The tool makes deployment a single command and is commonly used in CI/CD pipelines and as a package.json script.
How do I run a basic gh-pages example?
Run `npx gh-pages -d [dist]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -d, --dist _dir_ do in gh-pages?
Directory to deploy.