Using Git Not Github

June 2013

This is embarrassing because this is a pretty important concept that obviously just… escaped me. I figured I might as well do a quick write-up for anyone else who didn’t really get this because, well, I figure I’m not the only one:

Git and Github are not the same thing.

While I thought I understood this distinction, for a long time I thought that you needed both in order to actually use git. Turns out this isn't true. You can get the full benefits of git and all it’s versioning, merging, cloning glory without ever pushing your repo to Github or any other public storage site unless that’s what you wanted to do. This is great because for the longest time, while under this misconception, I was putting public repos up on GitHub to store them when they weren’t really open-source projects or anything useful to others like that: they were just things I needed to put somewhere, and I thought that GitHub was how I was supposed to store my git repos.

Anyway, here’s an example of how you might set up a remote repo with Dropbox if it was installed on your local machine:

Start with the files you’d like to make your local repo. I’m doing it with an Ember starter kit that eventually I want to store on Dropbox:

cd code mkdir ember-starter cd ember-starter git init touch README.md git commit -m "First commit"

Somewhere else, be it Dropbox, a harddrive, or some other cloud solution make a remote repo. I'm doing it by just making a folder on Dropbox to push to:

cd ~/Dropbox mkdir ember-starter cd ember-starter git init --bare

(The -—bare is important. What we’re doing is creating an empty repo to push our already created repo to.)*

Now that we’ve made the directory where are remote is, switch back to where all your starter files are. Mine are at ~/code. We’re going to tell it where its remote repo is:

cd ~/code/ember-starter git remote add origin ~/Dropbox/ember-starter

Now that we’ve pointed it to our remote repo, we can push our files:

git push -u origin master

Finished. Pretty simple, really.

Some articles that helped me write this:

Alternatives

Hosting your remote repos on Github is a pretty good idea - you have the ability to easily add collaborators, track stats, and it's all with the good vibes of open source. That said, if you really need private repos, their micro plans are pretty cheap, starting at $7/month. If you're a student, you can get two years of micro for free. There also is Git Lab, which is an open-source version of Github that seems promising (although I haven't tried it myself).

If you thought this was helpful, tell me on Twitter.