Browse code

Add functions for new GH repos.

Daniel Bolton authored on 06/08/2011 at 20:15:09
Showing 1 changed files
... ...
@@ -9,19 +9,13 @@ fi
9 9
 
10 10
 # https://github.com/dbb 
11 11
 
12
-# These are taken directly from the instructions you see after you create a new
13
-# repo. As the names imply, new_gh() assumes you're starting from scratch in a
14
-# directory named after the repo (this name is the only argument it takes), and
15
-# exist_gh() assumes that you've already initialized git in the given directory
16
-# (again, the only argument).
17
-# set up a new repo
18
-
19
-new_gh() { # [NAME_OF_REPO]
20
-    repo = $1
21 12
 
22
-    name=$(  igit config user.name )
23
-    email=$( git config user.email )
24
-    user=$(  git config github.user )
13
+# empty_gh [NAME_OF_REPO]
14
+#
15
+# Use this when creating a new repo from scratch.
16
+empty_gh() { # [NAME_OF_REPO]
17
+    repo = $1
18
+    ghuser=$(  git config github.user )
25 19
 
26 20
     mkdir "$repo"
27 21
     cd "$repo"
... ...
@@ -29,17 +23,37 @@ new_gh() { # [NAME_OF_REPO]
29 29
     touch README
30 30
     git add README
31 31
     git commit -m 'Initial commit.'
32
-    git remote add origin git@github.com:${user}/${name}.git
32
+    git remote add origin git@github.com:${ghuser}/${repo}.git
33
+    git push -u origin master
34
+}
35
+
36
+# new_gh [DIRECTORY]
37
+#
38
+# Use this when you have a directory that is not yet set up for git.
39
+# This function will add all non-hidden files to git.
40
+new_gh() { # [DIRECTORY]
41
+    cd "$1"
42
+    ghuser=$( git config github.user )
43
+
44
+    git init
45
+    # add all non-dot files
46
+    print '.*'"\n"'*~' >> .gitignore
47
+    git add ^.*
48
+    git commit -m 'Initial commit.'
49
+    git remote add origin git@github.com:${ghuser}/${repo}.git
33 50
     git push -u origin master
34 51
 }
35 52
 
53
+# exist_gh [DIRECTORY]
54
+#
55
+# Use this when you have a git repo that's ready to go and you want to add it
56
+# to your GitHub.
36 57
 exist_gh() { # [DIRECTORY]
37 58
     cd "$1"
38 59
     name=$( git config user.name )
39
-    email=$( git config user.email )
40
-    user=$( git config github.user )
60
+    ghuser=$( git config github.user )
41 61
 
42
-    git remote add origin git@github.com:${user}/${name}.git
62
+    git remote add origin git@github.com:${ghuser}/${repo}.git
43 63
     git push -u origin master
44 64
 }
45 65