This guide will help you install GitHub CLI, set up convenient aliases for quickly creating repositories, and use them.
sudo pacman -S github-clisudo apt update && sudo apt install ghAfter installation, check the functionality of the command:
gh --versionBefore using GitHub CLI you need to log in:
gh auth loginSelect GitHub.com, then your login method (browser or token).
To simplify repository creation, add the following aliases to your ~/.bashrc file:
echo "alias gh-create-readme='git init -b main && echo \"# init repo + README.md\" > README.md && \
git add README.md && git commit -m \"Initial commit\" && \
gh repo create --private --source=. --remote=origin && \
git push -u --all'" >> ~/.bashrc
echo "alias gh-create-main='git init -b main && git add . && git commit -m \"create local branch remote origin and push to remote.\" && \
gh repo create --private --source=. --remote=origin && \
git push -u --all'" >> ~/.bashrc
echo "alias gh-create-remote='git add . && git commit -m \"create remote origin and push to remote.\" && \
gh repo create --private --source=. --remote=origin && \
git push -u --all'" >> ~/.bashrc
source ~/.bashrc| Alias ββ | Description |
|---|---|
gh-create-readme |
Initializes the repository with main branch, creates README.md, commits and pushes it to GitHub to the new repo with same name as the current directory |
gh-create-main |
Initializes the repository with main branch, adds all files, commits and pushes them to GitHub to the new repo with same name as the current directory |
gh-create-remote |
Creates a remote repository with same name as the current directory and pushes the localy initiated repoitory with all branches to it (without git init) |
Run any of the following commands inside a project directory:
gh-create-readme # Initializes a repo with a README and pushes it to GitHub to the new repo with same name as the current directory
gh-create-main # Initializes a repo with all files and pushes it to GitHub to the new repo with same name as the current directory
gh-create-remote # Creates a GitHub repo from an existing local repo and pushes to the new repo with same name as the current directoryπ₯ Now creating and publishing repositories on GitHub is done in one command! π