Skip to content

NiaRiver/github_cli_automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 

Repository files navigation

πŸ“˜ GitHub CLI Automation Guide With aliases

This guide will help you install GitHub CLI, set up convenient aliases for quickly creating repositories, and use them.

πŸš€ Installing GitHub CLI

πŸ“Œ On Arch Linux (using pacman)

sudo pacman -S github-cli

πŸ“Œ On Debian/Ubuntu (using apt)

sudo apt update && sudo apt install gh

After installation, check the functionality of the command:

gh --version

πŸ”‘ Authorization in GitHub CLI

Before using GitHub CLI you need to log in:

gh auth login

Select GitHub.com, then your login method (browser or token).

⚑ Configuring Aliases

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 Descriptions

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)

🎯 Usage

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! πŸš€

About

GitHub CLI Automation with Aliases Simplify GitHub repository creation with CLI aliases! This repo provides setup instructions for GitHub CLI on Arch and Debian/Ubuntu, plus custom aliases to automate repo initialization, commits, and pushesβ€”all in a single command. πŸš€

Topics

Resources

Stars

Watchers

Forks

Contributors