Android OS Forum banner

1 - 1 of 1 Posts

·
Developer
Joined
·
194 Posts
Discussion Starter · #1 ·
Introduction

GitHub is a website used by many sites in the Android and Linux community for both private and public storage of code. There are some benefits to using this service over storing your code locally:

  • Can be easily shared and downloaded by others
  • Automatically stores multiple backups of your code
  • Color-coding
  • File type recognition
One con though, you cannot use tab for indentations like you could in other editing programs. However, if you copy text from a program like gedit it does retain the tabs and assign color codes of its own.

Downloading with GitHub

First we need to create an account at GitHub and then provide a way to securely connect our computer to their servers. The GitHub Setup website is going to provide you with the most information with setting up your GitHub account, but the basics are not that difficult. First you are going to want to open terminal and type:

Code:
sudo apt-get install git-core git-doc git-gui
Once downloaded, you will want to create a SSH key to upload to the GitHub website. To do this type (make sure to substitute the part in red for the email you used to sign up for GitHub):

Code:
ssh-keygen -t rsa -C "[COLOR="red"][email protected][/COLOR]"
And after you type that it'll ask you to enter the file you want to save the key, just hit enter. Next it'll ask for a passphrase that you'll be prompted for when connecting to GitHub, this doesn't have to be the same as the one you entered when signing up.

Now that your randomart image is generated, type the following command:

Code:
gedit ~/.ssh/id_rsa.pub
Copy and paste the entire contents of this file and upload it to the GitHub website under Account Settings -> SSH Public Keys -> Add another public key. If you have a lot of public keys, it might help to name it something easy to remember related to the particular computer that you're using (for example if you're using a virtual box for that git).

Code Retrieval

As part of the very brief explanation, let's say I found code in a public GitHub. How do I go about retrieving it? One of the simplest ways of doing that is Git Clone. This will take everything stored in a particular repository and clone it into a new directory. Of course, there are there ways to get code using commands like fetch and checkout, but the main thing that people are probably going to use here is most likely clone.

Example of Git Clone:

Code:
git clone [URL=git://gist.github.com/1026610.git]git://gist.github.com/1026610.git[/URL] gist-1026610
Will create the directory gist-1026610 and allow you to execute the code that is contained in that directory.

Is Git Free?

Yes and no. If you want to store code on Git but don't plan to do any major projects, they offer a free equivalent that doesn't grant quite as many benefits, but still allows people to download the code and allows private and public storage called Gist.
 
1 - 1 of 1 Posts
Top