[Android Software/Hacking General [Developers Only]] eagleeyetom:
Hi.

Today I would like to show you how to use github. I'm not an expert (I'm rather n00b TBH :p) but I learned some things and might help you with simple git commands.

1. Github? What's that?

In short it's the web-based hosting service for software development projects that use the Git revision control system. In English - the place where you store your sources.

2. Creating an account.

2.0 Download the required libs

sudo apt-get install git

2.1 Create an account on github.com website

2.2 In terminal type:

git config --global user.name "Your Name Here"
git config --global user.email "your_email@youremail.com"

NOTE: use the e-mail used in the website account creation

2.3 Create your unique SSH public key

ssh-keygen -t rsa -C "your_email@youremail.com"
# Creates a new ssh key using the provided email
# Generating public/private rsa key pair.
# Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]

Now you need to enter a passphrase.

# Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]

Which should give you something like this:

# Your identification has been saved in /c/Users/you/.ssh/id_rsa.
# Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@youremail.com

Now go to ~/.ssh folder and copy your id_rsa.pub content into account administration on github.com

... and check if everything works

ssh -T git@github.com

The authenticity of host 'github.com (207.97.227.239)' can't be established.
# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
# Are you sure you want to continue connecting (yes/no)?

Duh?! Sure I want! Yes! Yes! Yessss!

# Hi username! You've successfully authenticated, but GitHub does not
# provide shell access.

And we are ready to do some serious things! :highfive:

3. Forking a repo

As an example I'll use https://github.com/CyanogenMod/android_packages_apps_Settings

Open this link in the browser and click fork.

3.1 Clone the source from your fork.

I use my account as an example.

git clone git://github.com/eagleeyetom/android_packages_apps_Settings.git -b gingerbread

-b gingerbread let us to choose what branch are we going to download

3.2 Do some changes!

For example add files, remove them etc.

3.3 Commit the changes

OPTIONAL I created new branch at my project and named it "xda"

To do this go to the cloned folder and type:

git branch xda
git checkout xda

Now it's time to see what's going on:

Magic command

git status

As you can see I removed few files and added one.

Now it's time to tell the git what we want to do.

4. Pushing the changes

Add all modified files:

git add .

Add all removed files

git add -u

You can also add/rm one file

git add name_of_file
git rm name_of_file

After git status we should get something like this:

Now it's time to commit:

git commit -m 'my first commit'

And finally to push:

git push

If you'll get some errors use the following:

git push git@github.com:eagleeyetom/android_packages_apps_Settings.git xda

I used the name of my github and the name of the branch in the end.

Woo hoo! Now let's check the website.

That's the most basic basics :p

In the next posts I will show you some more advanced commands like merge, cherry-pick, removing branches etc.

:)

Credits:

Google :D

Github Team

All my friends from GingerDX IRC channel

If you find it useful hit thanks button. You can also consider a small donation ;)