Skip to content

Instantly share code, notes, and snippets.

@samuraijane
Created August 12, 2020 02:00
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 samuraijane/41baf9760d5accdc6ab6f2d8b6fa60af to your computer and use it in GitHub Desktop.
Save samuraijane/41baf9760d5accdc6ab6f2d8b6fa60af to your computer and use it in GitHub Desktop.
#let Terminal know that you are using bash shell (the line that begins with '#!' is known as the interpreter line)
#!/bin/sh
#set the version number for this
#version 0.0.3 (8 July 2016)
#create a variable to hold the name of the new repository
#the '$1' denotes the first argument passed to this shell
#for example, entering 'xxr repo-name' in Terminal stores the first argument, or 'repo-name', in the variable 'repo'
repo=$1
#have terminal check to see if the user entered a name for the new repository
#if a name was not entered, let the user know that a name is required
test -z $repo && echo "To create a repository, you must include its name, like this: \"xxr repo-name\"" 1>&2 && exit 1
#initialize the local current directory with a local git repository
git init
#create the repository at GitHub and make it private
curl -u 'samuraijane' https://api.github.com/user/repos -d "{\"name\":\"$repo\", \"private\":\"true\"}"
#add an alias of the GitHub repository to the local git repository stored on your machine
#the name of the alias is 'origin'
git remote add origin https://github.com/samuraijane/$repo".git"
#create the files that every git repository should have by default
touch README.md
touch .gitignore
touch LICENSE.md
#perform the first commit (which, in this case, is empty)
git commit -m 'Initial commit' --allow-empty
#push the current local version of the project to GitHub and create a local master branch that is tracked upstream (not sure if I am wording this correctly)
git push -u origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment