Mastering GitHub CLI on Termux: A Complete Guide 🚀

post9.jpg

GitHub CLI (gh) is a powerful command-line tool that lets you interact with GitHub directly from your terminal. In this guide, we’ll explore how to install, configure, and use gh on Termux (Android’s terminal emulator) like a pro! 🔥


📥 Installation

First, ensure your Termux is up-to-date:

pkg update && pkg upgrade -y

Install GitHub CLI with just one command:

pkg install gh -y

Verify installation:

gh --version

✅ Done! You now have gh installed.


🔐 Authentication

To use gh, you need to log in to your GitHub account:

gh auth login

Follow the prompts:

  • Choose GitHub.com (default).
  • Select HTTPS for authentication.
  • Login via browser (copy-paste the one-time code).

🎉 You’re now authenticated!


🛠 Basic Commands

🔍 View Profile & Repos

gh api user
gh repo list

📂 Clone a Repository

gh repo clone <username>/<repo>

Create a New Repo

gh repo create <repo-name> --public --clone

Delete a Repository

gh repo delete <repo-name> --confirm

⚠️ Warning: This permanently deletes the repository! Use with caution.

🔄 Push Changes

git add .
git commit -m "Your message"
gh pr create

🏷 Manage Pull Requests

gh pr list
gh pr checkout <PR-number>
gh pr merge <PR-number>

🏷 Work with Issues

gh issue list
gh issue create --title "Bug fix" --body "Description"
gh issue close <issue-number>

🚀 Advanced Usage

🔄 GitHub Actions

gh workflow list
gh run watch

🔎 Search Repos & Code

gh search repos "termux"
gh search code "github cli"

📦 Gists (Pastebin Alternative)

gh gist create myfile.txt --public
gh gist list

💡 Pro Tips

  • Use gh alias to create shortcuts for frequent commands.
  • Enable autocomplete for gh in Termux:
    gh completion -s bash >> ~/.bashrc
    source ~/.bashrc
    
  • Check gh help for more commands.

Troubleshooting

“gh: command not found”

Reinstall gh:

pkg install gh -y

🔑 Authentication Issues

Log out and log back in:

gh auth logout
gh auth login

🎯 Conclusion

GitHub CLI (gh) makes GitHub workflows seamless, even on Termux! Whether you’re managing repos, PRs, or issues, gh has you covered. 🚀

📢 Now go automate your GitHub workflow like a boss! 💪

🔗 Official Docs: GitHub CLI Documentation


📌 Tags:
#GitHub #Termux #CLI #DevOps #Automation

Latest Posts