Skip to content
> ๐Ÿ’ป ๐Ÿง  ืงื•ื“ 1001 > > Git > GitHub > ืžื” ื–ื” GitHub CLI?

ืžื” ื–ื” GitHub CLI?

CLI ื ื•ื— ืœืžืคืชื—ื™ื, ืžื”ื ื“ืกื™ DevOps ื•ืœื›ืœ ืžื™ ืฉืžื‘ืฆืข ืื•ื˜ื•ืžืฆื™ื” ืฉืœ ืขื‘ื•ื“ื” ืขื GitHub ืื• ืžืขื“ื™ืฃ ืืช ื”ื˜ืจืžื™ื ืœ ืขืœ ืคื ื™ ื”ื“ืคื“ืคืŸ.


ื”ืชืงื ื”

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ืงื‘ืœืช ื”ื’ื“ืจื•ืช CLIgh 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ื™ืฆื™ืจืช issuegh issue create --title "Bug" --body "Steps..."
gh issue viewื”ืฆื’ืช issuegh issue view 42
gh issue closeืกื’ื™ืจืช issuegh issue issue close 42

๐Ÿ”€ Pull Requests

ืคืงื•ื“ื”ื™ื™ืขื•ื“ื“ื•ื’ืžื”
gh pr listืจืฉื™ืžืช PRgh pr list
gh pr createื™ืฆื™ืจืช PRgh pr create --base main --head feature-x
gh pr viewื”ืฆื’ืช PRgh pr view 123 --web
gh pr checkoutืžืขื‘ืจ ืœืขื ืฃ PRgh pr checkout 123
gh pr mergeืžื™ื–ื•ื’ PRgh pr merge 123 --squash --delete-branch

๐Ÿ“ฆ Releases

ืคืงื•ื“ื”ื™ื™ืขื•ื“ื“ื•ื’ืžื”
gh release listืจืฉื™ืžืช releasesgh release list
gh release createื™ืฆื™ืจืช releasegh release create v1.0.0 --notes "First release"
gh release uploadื”ื•ืกืคืช ืงื•ื‘ืฅ ืœ-releasegh release upload v1.0.0 build.zip
gh release viewื”ืฆื’ืช releasegh release view v1.0.0

๐Ÿ“œ Gists

ืคืงื•ื“ื”ื™ื™ืขื•ื“ื“ื•ื’ืžื”
gh gist createื™ืฆื™ืจืช gistgh gist create file.txt
gh gist listืจืฉื™ืžืช gistsgh gist list
gh gist viewื”ืฆื’ืช gistgh gist gist view abc123
gh gist editืขืจื™ื›ืช gistgh gist edit abc123

โš™๏ธ Workflows (GitHub Actions)

ืคืงื•ื“ื”ื™ื™ืขื•ื“ื“ื•ื’ืžื”
gh workflow listืจืฉื™ืžืช workflowsgh workflow list
gh workflow viewื”ืฆื’ืช workflowgh workflow view build.yml
gh workflow runื”ืคืขืœืช workflowgh workflow run build.yml
gh run listืจืฉื™ืžืช ื”ืจืฆื•ืชgh run list
gh run watchืžืขืงื‘ ืื—ืจ ื”ืจืฆื”gh run watch 123456789

ื›ืชื™ื‘ืช ืชื’ื•ื‘ื”

ื”ืื™ืžื™ื™ืœ ืœื ื™ื•ืฆื’ ื‘ืืชืจ. ืฉื“ื•ืช ื”ื—ื•ื‘ื” ืžืกื•ืžื ื™ื *