Its easy to create a new repository on Github website and then use your git tool or command line to clone it or add that remote repository to your project on your development machine. It would be even easier if you could just do it all from the command line with one command. Well, if you install Hub then you can!
brew install hub
I havent got round to using homebrew yet, so I just installed hub in my home binaries directory:
curl http://defunkt.io/hub/standalone -sLo ~/bin/hub
Then I just make hub executable and I am good to go
I could alias hub as the git command as suggested by the hub website, however I want to see the advantages of hub before I fully commit to it.
Creating a Github repo without using the website
In this example I am putting my configuration files onto Github (because after I installed rvm it started rewriting things) so I can manage them better and share them with others.
As usual, I start by creating a local repository for my project files. This case I am in the home directory.
To start with I am just going to add my global git configuration files to the repository. I’ll add more later.
git status I can see I have the desired files ready to be committed. So lets commit them to my local repository with a suitably clear message.
Now my git global configuration files are committed locally, so if they change I will be able to compare then to what is in git.
So far I haven’t needed to use Hub, but now I want to share these configuration files via Github. I could go onto the website and then come back to the command line and add a remote for the Github repository I just added. Using hub, I can just stay in the command line.
Using hub create command I can create a repository on Github, specifying the name of the repository and using the -d option I can also include a description
A repository on Github has been created and the remote address was automatically added to my local git project. Yay!
To make absolutely sure just this first time, I have a quick look on the Github website and sure enough there is my new repository.
Okay, so now I have a shiny new repo on github, its time to push my changes to it from my local repository. Again, we are back to just using git commands.
To check everything is up to date on both the local and remote repositories, I do a quick git log and see (thanks to my git log customisations) that the remote repository (origin/master) is at the same commit version as my local repository (master).
There is a lot more to hub that I will try out, but the most immediate use is to be able to create a Github repository without having to switch from the command line.
This work is licensed under a Creative Commons Attribution 4.0 ShareAlike License, including custom images & stylesheets. Permissions beyond the scope of this license may be available at @jr0cket