Subscribe to A Programmer's Casual Blog        RSS Feed
-----

Code Collaboration with Github (now in 720p)

Icon Leave Comment
It wasn't but a couple months ago that I had no idea how to maintain my code. I was programming with C# and was working on a project that I literally put hundreds of hours into. After that much time, as the project started to evolve, I began to fear that some change that I might make today... would break all of the code that I did over the past month. Like any rational human, I didn't want to use an overly complicated method of preserving the history of my project, so I simply created a folder called "BACKUPS" and pasted copies of my project into it every day I worked on it.

Of course, not only did this make me feel like a complete goof, but it was also difficult to figure out where exactly my code took "drastic turns" as code often does in long term projects.

It wasn't until a couple months ago that I discovered version control through git was not only a feature rich way of safely maintaining my code, but it was also a simpler to use system than copying and pasting my code into a "backups" folder.

If you want your code to be as private as possible, you can always use git completely offline (I prefer to do this for my work code). But you also have the option of uploading your code to github.com where you will have access to it from everywhere on earth, and if you spend a little time marketing/campaigning on the internet, you can even draw people into your project to collaborate with you.

The below video tutorial series demonstrates the installation and usage of git, gas and github.com on a linux system. This all applies to windows too, but you need to use the windows version of ruby and git. And you need to use the special "gitbash" or "cygwin" terminal windows to upload from windows.


1 Prerequisites: Installing ruby, curl, and git on your linux machine


Commandline Run-Down: installation stuff...
$  apt-get update
$  apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf

$  bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

$  echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc

<LOGIN AND OUT OF SSH>

$  rvm pkg install zlib
$  rvm install 1.9.2
$  rvm --default use 1.9.2





2 Online Configurations: Setting up your github.com account
http://www.youtube.c...h?v=uagaj3TLEnc (video limit is 2 here...)

Commandline Run-Down: github stuff...
<Create a free account at github.com>

<Create a new repository with your github account>





3 Final stages and summary of GAS, a gem that makes it simpler



Commandline Run-Down: Git, Gas and GitHub.com

Install the gem "gas"...
$  gem install gas



Create a new user and choose default to all the prompts until you're prompted for your github.com username and password.
$  gas add <short nickname>  "<your git author name>" <[email protected]>



Spoiler


Tell gas to set your new user as the current github author...
IMPORTANT: If you already have a key called ~/.ssh/id_rsa then you should copy this key and its .pub counterpart somewhere else before telling gas to overwrite the key. If you told gas to use this key as this author's rsa key, then it will already have been backed up and you won't even be prompted about it.
$  gas use <short nickname>





Setup a local git repository with a brand new code project in it...
$  mkdir new_tmp_folder; cd new_tmp_folder
$  git init

$  touch my_source_Code.rb

$  git add .
$  git commit -m "initial commit"

$  git remote add origin <COPY THE REST OF THE CORRESPONDING LINE FROM YOUR GITHUB REPOSITORY PAGE YOU MADE EARLIER...>

$  git push -u origin master




Make your first change to your source code...
$  echo 'puts "This is my first edit to my source code!"' >> my_source_code.rb     # this puts a new line of code into your source file




Now, update your repository to track in this progress...
$  git add .
$  git commit -m "Made an edit to my code"

$  git push




You can now do all sorts of wonderful things like clone your github repository to another computer, and upload changes you make from there...
$  git clone <SSH ADDRESS TO YOUR GITHUB REPOSITORY>

<make changes>

$  git push origin





And you can pull down those changes from your original PC...
$  git pull






I do a little more explaining in the vids and of course visually walk you through setting up a github account and repo which might help (see the second vid). See you on github =)

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

July 2018

S M T W T F S
1234567
891011121314
151617181920 21
22232425262728
293031    

Tags

    Recent Comments

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)

    Categories