GitHub CLI (ืืงืืฆืืจ gh) โ ืืื ืืื ืฉืืจืช ืคืงืืื ืืืืคืฉืจ ืืขืืื ืขื GitHub ืืฉืืจืืช ืืืืจืืื ื. ืืืืฆืขืืชื ื ืืชื ืื ืื ืืืืจืื, issues, pull requests, releases ืืืฉืืืืช ืืืจืืช, ืืืื ืืืืื ืก ืืืืฉืง ืืืื ืืจื ื ืฉื GitHub.
CLI ื ืื ืืืคืชืืื, ืืื ืืกื DevOps ืืืื ืื ืฉืืืฆืข ืืืืืืฆืื ืฉื ืขืืืื ืขื GitHub ืื ืืขืืืฃ ืืช ืืืจืืื ื ืขื ืคื ื ืืืคืืคื.
- ืืชืงื ื
- ืืืืืช
- ืืืืืืช ืขืืงืจืืืช
- ืคืงืืืืช ืฉืืืืฉืืืช
- ืืชืจืื ืืช GitHub CLI
- 1. ืืืืืช
- 2. ืืืืงืช ืกืืืืก ืืืืืช
- 3. ืฉืืคืื ืืืืจ
- 4. ืืฆืืจืช ืืืืจ ืืืฉ
- 5. ืืฆืืช ืืืืข ืขื ืืืืจ
- 6. ืจืฉืืืช issues
- 7. ืืฆืืจืช issue
- 8. ืืฆืืจืช Pull Request
- 9. ืืฆืื ืืืืืงืช PR
- 10. ืืืืื PR ืขื ืืืืงืช ืขื ืฃ
- ๐ ืืืืืช ืืืืืจืืช
- ๐ ืืืืจืื
- ๐ Issues
- ๐ Pull Requests
- ๐ฆ Releases
- ๐ Gists
- โ๏ธ Workflows (GitHub Actions)
ืืชืงื ื
GitHub CLI ื ืชืื ื-Windows, macOS ื-Linux.
- Linux (Ubuntu/Debian):
sudo apt install gh
- macOS (ืืจื Homebrew):
brew install gh
- Windows (ืืจื Winget):
winget install --id GitHub.cli
ืืืืจ ืืืชืงื ื, ืืืืง ืืช ืืืจืกื:
gh --version
ืืืืืช
ืืื ืืงืื ืืืฉื ืืืืืจืื ืืคืขืืืืช ืคืจืืืืช, ืขืืื ืืืืช:
gh auth login
CLI ืืฆืืข:
- ืืืืืจย GitHub.comย ืื GitHub Enterprise
- ืฉืืืช ืืืืืช (ืืคืืคื, ืืืงื, SSH)
- ืืฉืืืจ ื ืชืื ืื ืืืคืขืืืช ืืืืืช
ื ืืชื ืืืืืง ืืช ืืกืืืืก ืืืืฆืขืืช ืืคืงืืื:
gh auth status
ืืืืืืช ืขืืงืจืืืช
ืขืืืื ืขื ืืืืจืื
ืืฆืืจืช ืืืืจ ืืืฉ:
gh repo create my-project
ืฉืืคืื:
gh repo clone owner/repo
ืืฆืืช ืืืืข:
gh repo view owner/repo
Issues
ืืฆืืจืช issue:
gh issue create --title "Bug: crash on startup" --body "Steps to reproduce..."
ืจืฉืืืช issues:
gh issue list
ืืฆืืช issue ืกืคืฆืืคื:
gh issue view 42
Pull Requests
ืืฆืืจืช pull request:
gh pr create --base main --head feature-branch --title "New feature" --body "Added new functionality"
ืืฆืื:
gh pr list
gh pr view 123
ืืืืื:
gh pr merge 123 --squash --delete-branch
Actions (CI/CD)
ืืคืขืืช workflows:
gh workflow run build.yml
ืืฆืืช ืกืืืืก:
gh run list
ืคืงืืืืช ืฉืืืืฉืืืช
| ืคืงืืื | ืืืขืื |
|---|---|
gh help | ืจืฉืืืช ืื ืืคืงืืืืช |
gh alias set co "pr checkout" | ืืฆืืจืช ืืื ืื ืืคืงืืื ืืืืจื |
gh gist create file.txt | ืืขืืืช ืงืืืฅ ื-gist |
gh release create v1.0.0 | ืืฆืืจืช release |
ืืชืจืื ืืช GitHub CLI
- ืืืกืืื ืืืื: ืขืืืื ืขื GitHub ืืื ืืคืืคื.
- ืกืงืจืืคืืื: ื ืื ืืืืืืืฆืื ื-bash/PowerShell.
- ืืื ืืืจืฆืื ืขื CI/CD.
- ืืื ืืืื ืืคืงืืืืช ื-GitHub API.
ืืฆืืื ๐ ืื ืืืื ื ืืฆืืจ ืจืฉืืืช ืืืืงื "10 ืืคืงืืืืช ืืืืืืืืช ืฉื GitHub CLI ืืฉืืืืฉ ืืืืืืื". ื ืืชื ืืืฉืชืืฉ ืื ืืืฃ ืขืืจ.
โ 10 ืืคืงืืืืช ืืืืืืืืช ืฉื GitHub CLI ืืฉืืืืฉ ืืืืืืื
1. ืืืืืช
gh auth login
๐ ืืืืืช ื-GitHub ืืจื ืืคืืคื ืื ืืืงื. ืฉืืืืฉื ืืืืืจื ืจืืฉืื ืืช ืื ืฉืื ืื ืืฉืืื.
2. ืืืืงืช ืกืืืืก ืืืืืช
gh auth status
๐ ืืืืง ืื ื-CLI ืืืืืจ ื-GitHub ืืืืฆื.
3. ืฉืืคืื ืืืืจ
gh repo clone owner/repo
๐ฅ ืฉืืคืื ืืืืจ ืฉื ืืืืจ ืืื ืืืคืืฉ ืงืืฉืืจ ืืืืฉืง ืืืื ืืจื ื.
4. ืืฆืืจืช ืืืืจ ืืืฉ
gh repo create my-project
๐ ืืฆืืจืช ืืืืจ ืืฉืืจืืช ืืืืจืืื ื (ืืงืืื + ื-GitHub).
5. ืืฆืืช ืืืืข ืขื ืืืืจ
gh repo view --web
๐ ืืฆืื ืชืืืืจ ืืืืืจืืช ืืืืจ. ืืคืฉืจืืช --web ืคืืชืืช ืืื ืืช ืืืฃ ืืืคืืคื.
6. ืจืฉืืืช issues
gh issue list
๐ ื ืื ืืืฆืืช ืืฉืืืืช ืืืืืื ืืฉืืจืืช ืืืจืืื ื.
7. ืืฆืืจืช issue
gh issue create --title "Bug: login failed" --body "Steps to reproduce..."
๐ ืืืฆืจ ืืฉืืื ืืืฉื ืื ืืื ืืืืื.
8. ืืฆืืจืช Pull Request
gh pr create --base main --head feature-branch --title "New feature" --body "Description..."
๐ ืืื ืขืืงืจื ืืขืืืืช ืฆืืืช: ืคืชืืืช Pull Request ืืืขื ืฃ ืฉืื.
9. ืืฆืื ืืืืืงืช PR
gh pr view 123
๐ ืืฆืืช Pull Request ืขื ืืขืจืืช ืืกืืืืกื ืืืืงื. ื ืืชื ืืืืกืืฃ --web ืืื ืืคืชืื ืืืคืืคื.
10. ืืืืื PR ืขื ืืืืงืช ืขื ืฃ
gh pr merge 123 --squash --delete-branch
โ ืืืืื Pull Request + ืืืืงืช ืขื ืฃ ืืฆืขื ืืื.
๐ GitHub CLI โ ืืฃ ืขืืจ
๐ ืืืืืช ืืืืืจืืช
| ืคืงืืื | ืืืขืื | ืืืืื |
|---|---|---|
gh auth login | ืืืืืช (ืืคืืคื, ืืืงื, SSH) | gh auth login |
gh auth status | ืืืืงืช ืืืืืจ ื ืืืื | gh auth status |
gh alias set co "pr checkout" | ืืฆืืจืช ืืื ืื ืืคืงืืื ืืืืจื | |
gh config get | ืงืืืช ืืืืจืืช CLI | gh config get editor |
๐ ืืืืจืื
| ืคืงืืื | ืืืขืื | ืืืืื |
|---|---|---|
gh repo create | ืืฆืืจืช ืืืืจ | gh repo create my-project |
gh repo clone | ืฉืืคืื ืืืืจ | gh repo clone hypo69/hypotez |
gh repo view | ืืืืข ืขื ืืืืจ (ืื ืคืชืืื ื-web) | gh repo view --web |
gh repo fork | ืืฆืืจืช ืคืืจืง ืืืืืจ | gh repo fork owner/repo |
๐ Issues
| ืคืงืืื | ืืืขืื | ืืืืื |
|---|---|---|
gh issue list | ืจืฉืืืช ืืฉืืืืช | gh issue list |
gh issue create | ืืฆืืจืช issue | gh issue create --title "Bug" --body "Steps..." |
gh issue view | ืืฆืืช issue | gh issue view 42 |
gh issue close | ืกืืืจืช issue | gh issue issue close 42 |
๐ Pull Requests
| ืคืงืืื | ืืืขืื | ืืืืื |
|---|---|---|
gh pr list | ืจืฉืืืช PR | gh pr list |
gh pr create | ืืฆืืจืช PR | gh pr create --base main --head feature-x |
gh pr view | ืืฆืืช PR | gh pr view 123 --web |
gh pr checkout | ืืขืืจ ืืขื ืฃ PR | gh pr checkout 123 |
gh pr merge | ืืืืื PR | gh pr merge 123 --squash --delete-branch |
๐ฆ Releases
| ืคืงืืื | ืืืขืื | ืืืืื |
|---|---|---|
gh release list | ืจืฉืืืช releases | gh release list |
gh release create | ืืฆืืจืช release | gh release create v1.0.0 --notes "First release" |
gh release upload | ืืืกืคืช ืงืืืฅ ื-release | gh release upload v1.0.0 build.zip |
gh release view | ืืฆืืช release | gh release view v1.0.0 |
๐ Gists
| ืคืงืืื | ืืืขืื | ืืืืื |
|---|---|---|
gh gist create | ืืฆืืจืช gist | gh gist create file.txt |
gh gist list | ืจืฉืืืช gists | gh gist list |
gh gist view | ืืฆืืช gist | gh gist gist view abc123 |
gh gist edit | ืขืจืืืช gist | gh gist edit abc123 |
โ๏ธ Workflows (GitHub Actions)
| ืคืงืืื | ืืืขืื | ืืืืื |
|---|---|---|
gh workflow list | ืจืฉืืืช workflows | gh workflow list |
gh workflow view | ืืฆืืช workflow | gh workflow view build.yml |
gh workflow run | ืืคืขืืช workflow | gh workflow run build.yml |
gh run list | ืจืฉืืืช ืืจืฆืืช | gh run list |
gh run watch | ืืขืงื ืืืจ ืืจืฆื | gh run watch 123456789 |