Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@richeney
Last active April 21, 2023 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richeney/43e8e9507e717008ac67acd39c532c8c to your computer and use it in GitHub Desktop.
Save richeney/43e8e9507e717008ac67acd39c532c8c to your computer and use it in GitHub Desktop.
Initialise Git repo from WSL2

Initialise git repo, push into GitHub

Needs git and gh.

Quick bashrc function

Add to .bashrc

github() {
    [[ "$1" != "init" ]] && return
    parent=$(builtin cd "$PWD/.." && pwd)
    if [[ "$parent" == "/home/richeney" || "$parent" == "/git" ]]
    then
      git init
      gh repo create $(basename $PWD) --public --source=.
    else
      echo "Parent directory is neither /home/richeney nor /git"
    fi
}

Step by step

Example:

mkdir multitenanted_aks && cd multitenanted_aks
git init
Initialized empty Git repository in /git/multitenanted_aks/.git/
echo "# Multi-tenanted AKS with workload identities" > README.md
git add --all
git commit -a -m "Initial commit"
[main (root-commit) c0864ce] Initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
gh repo create

And follow the prompts. Or:

gh repo create $(basename $PWD) --public --source=. --add-readme
code ,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment