- Must have Git installed.
- Must have GitHub CLI installed.
- Create a file
git-create-repo.sh
in your home directory and save the content ofgit-create-repo.sh
below in the file. - Add a Git alias called
create-repo
that runs the script:
git config --global alias.create-repo "! ~/git-create-repo.sh"
- Make the file executable:
chmod +x ~/git-create-repo.sh
- Use the Git alias inside the directory for which you're creating the GitHub repository, like this:
git create-repo [<repo-name>]
If no repository name is provided, the script will fallback to the directory name.
If you're not already logged into the GitHub CLI, you'll be prompted to do so. From there, create-repo
will initialise a new Git repository (if it isn't initialised already), create the repository on GitHub with GitHub CLI, and push an initial commit. Make sure to have .gitignore
setup to prevent adding files you don't want exposed to the Git history. It'll then ask you to press Enter or Return to open the repository page on GitHub in your default browser.
Okay, I just noticed by having GitHub Desktop, you don't need this script 😒. Just run:
Due diligence, Gyen. Due diligence! 🤦♂️