-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit-create
executable file
·33 lines (30 loc) · 1.04 KB
/
git-create
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
#This is meant to be run on a new folder or git repo with no commits to
#post straight to github.
if [ -z "$1" ];then
repo_name=${PWD##*/}
elif [ "${PWD}" == "${HOME}" ];then
echo Do not make your home directory a Git repo.
else
repo_name=$1
fi
echo $repo_name
test -z $repo_name && echo "Repo name required." 1>&2 && exit 1
#This assumes you have a auth token set to this $GITHUB_AUTHTOKEN
REMOTE="`git remote`"
if [ -z "${REMOTE}" ];then
echo no remote
if [ ! -z "${GITHUB_AUTHTOKEN}" ];then
curl -u $GITHUB_AUTHTOKEN:x-oauth-basic https://api.github.com/user/repos -d "{\"name\":\"$repo_name\"}"
git init
echo "Making this repository ignore all .folders"
echo ".*/" > .gitignore
echo "This will be your repo's readme" | tee README.md
git add .
git commit -m "Initial Commit"
git remote add origin "git@github.com:$GITHUB_USERNAME/$repo_name.git"
git push --set-upstream origin master
fi
else
echo This is already a git repo with a remote.
fi