Git / GitHub – Starter Guide

January 7, 2013 2 comments

Git is one of the most common source version control nowadays, and the most popular public server is

For newbie, it’s certainly difficult to start using Git at the beginning, so I decide to write this article in order to help any beginners to walk through this first start.

The environment used in this tutorial is: Windows (any version) and Cygwin command-line.

First, you need to get Cygwin from here. When you launch Cygwin to install packages, please type “git” in the package search to to check it.

Cygwin - Select Git package

Cygwin – Select Git package

Then wait for installation to be done.

Next is to visit: , and register an account.

Now, launch Cygwin command-line and start to work with GitHub repositories.

There are two methods to work with Github, one is over HTTPS, the other is over SSH.

Personally, I prefer to work over SSH so the following guide will be it.

Step 1: Create a SSH key

$ ssh-keygen -t rsa -C ""
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xjaphx/.ssh/id_rsa):
Created directory '/home/xjaphx/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/xjaphx/.ssh/id_rsa.
Your public key has been saved in /home/xjaphx/.ssh/
The key fingerprint is:
The key's randomart image is:

The above command will create a RSA-implemented key for email ““. So you’ve can just replace by your own email address for your key.

Step 2: Add newly-created SSH key to GitHub account

In order for GitHub account to acknowledge your work, you need to add your key to your account.

Go to GitHub, go to Account Settings -> SSH Keys, and click the button Add SSH Key.

Title: any name you want to recognize your device, well, your Git environment.

Key: simple, paste the content of your created SSH key, open file “” above.

Step 3: Execute ssh-agent for handle SSH work

You need to run SSH-agent always when work over SSH protocol.

$ exec ssh-agent bash

If you don’t run it, you will get this error message, when typing the following command:

$ ssh-add -l
Could not open a connection to your authentication agent.

Step 4: Config Git environment (optional)

This step is optional, but it is very helpful, when you are using Git on this environment frequently.

$ git config --global "your_github_account"
$ git config --global "your_github_email"
$ git config --global color.diff auto
$ git config --global color.status auto
$ git config --global color.branch auto

The first two commands is to save your global config of your GitHub account, so you don’t need to input username and email everytime accessing your repo.
The following three commands will identify to support color, it’s pretty handy for command users to see the diffs.

Step 5: Connect to GitHub through SSH

Try to issue this command to connect to GitHub

$ ssh
The authenticity of host ' (' 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)? yes
Warning: Permanently added ',' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi xjaphx! You've successfully authenticated, but GitHub does not provide shell access.
Connection to closed.

Remember to type exactly the above command!!!
If you get the following message like above output, you’re set for GitHub environment.

Step 6: Create a repo and test

Logging into in browser and follow this URL to create new repo: Create new repo

For sample, I create a new repo named “GitDemo“, so the Git URI to work on this repo is: , whereas “xjaphx” is my username, replace it by yours.

Now on Cygwin cmd-line, I will get this repo to local.

$ git clone
Cloning into 'GitDemo'...
warning: You appear to have cloned an empty repository.

Ok, well, navigate to this GitDemo directory and add/remove some file for testing purposes.

$ cd GitDemo

$ touch sample.c

$ git add sample.c

$ git commit -m "add new source file"
[master (root-commit) 28a2f82] add new source file
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 sample.c

$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 221 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
 * [new branch]      master -> master

Ok, so now in browser of your repo, you will see a new file “sample.c” in Files tab.
That’s how to add file.

Do the following step to remove a file

$ git rm sample.c
rm 'sample.c'

$ git commit -m "remove unecessary file"
[master 1fe4824] remove unecessary file
 0 files changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 sample.c

$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (2/2), 205 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
   28a2f82..1fe4824  master -> master

That’s it for the very very easy steps to learn Git and use GitHub!

You can google to find more resources to learn more about Git.

These are some references, I think you should read to kick a start learning.

TutsPlus – Eay Version Control with Git / GitHub


GitHub Learning Center

GitHub Help

GitHub – Code School

If you have any problem working with Git, feel free to post it here, you’re all welcomed!


Pete Houston

Categories: Git / Tags: ,

Display three dot ‘…’ in tail if text appears longer than container

November 22, 2012 Leave a comment

This is one of CSS trick I just found out to display three dot if the text size is longer than its container.

The following attributes must be set in order to work

#id_three_dot {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

Pete Houston

Categories: CSS Tags: , , ,

Linux ‘locate’ command

November 13, 2012 Leave a comment

The command ‘locate’ is pretty useful for searching something on system.
Here some uses of it.

1. To find my Apache config file:

$ locate httpd.conf

2. To count to number of results output

$ locate httpd.conf -c

3. To limit the number of results display, 10 for example

$ locate httpd.conf -l 10

Pete Houston

Categories: Bash, Linux Tags: , ,

Vi – Highlight current cursor line

November 8, 2012 Leave a comment

In order to highlight current line where cursor stays, use this command: [ :set cursorline ]
So it will highlight the line every line cursor moving to.
It might result slow in Vi/Vim if the file is too big.

Pete Houston

Categories: Vi / Vim Tags: ,

Vi – Delete all file contents

October 23, 2012 1 comment

To remove / delete all file contents, use this command: dG

Pete Houston

Categories: Tools, Vi / Vim Tags: , ,

Try2Hack – Level 4

October 18, 2012 1 comment

Level 4

Open it in Chrome, see nothing. So I try to view source code:

 <!--[if !IE]>-->
  <!--[if !IE]>-->

Well, it’s some sort of Java Applet, then I switch to IE to open it. Yes, it’s running, require a login id and a password to reach next level.
Download this file: PasswdLevel4.class

And then use a Java Decomplier to view source code, I use JD-GUI for this task. Here the part of code that need attention:

   this.infile = new String("level4");
      this.inURL = new URL(getCodeBase(), this.infile);
    catch (MalformedURLException localMalformedURLException)
      getAppletContext().showStatus("Bad Counter URL:" + this.inURL);

Well, then it must be reading the login id and password in a file, then compare with the value input into two textboxes for verification.
Download this file: level4

It’s a hex file, so use a Hex Viewer to read. One of my favorite one is: WebHex, an online hex-viewer.

here the result :

 	00	01	02	03	04	05	06	07	08	09	0A	0B	0C	0D	0E	0F	0123456789ABCDEF
000000	00	6C	65	76	65	6C	35	2D	66	64	76	62	64	66	2E	78	.level5-fdvbdf.x
000010	68	74	6D	6C	0D	0A	61	70	70	6C	65	74	6B	69	6E	67	html..appletking
000020	0D	0A	70	69	65	63	65	6F	66	63	61	6B	65	0D	0A	 	..pieceofcake..

So, try to log in with: __user | pass = appletking | pieceofcake__
Yeah, reach to next level..~

Pete Houston

Try2Hack – Level 3

October 18, 2012 29 comments

Level 3

Now what interesting? Right after finish loading, it requires to prompt the input password.

Again using the cool tool: Web Sniffer for this job.

Here the part of all Javascript on page of level 3:

    <script type="text/javascript" src="JavaScript"></script>[CRLF]
    <script type="text/javascript">[CRLF]
      pwd = prompt("Please enter the password for level 3:","");[CRLF]
      if (pwd==PASSWORD){[CRLF]
        alert("Allright!\nEntering Level 4 ...");[CRLF]
        location.href = CORRECTSITE;[CRLF]
      else {[CRLF]
        alert("WRONG!\nBack to disneyland !!!");[CRLF]
        location.href = WRONGSITE;[CRLF]

First look up, try with password = __AbCdE__, but fail…lol?!?! Reason why?
After looking up carefully, here the trick of the magic.

<script type="text/javascript" src="JavaScript">

It must be something in this file: Javascript

Downloaded and view what’s inside.

PASSWORD = "try2hackrawks";
CORRECTSITE = "level4-kdnvxs.xhtml";

Well, prompt the password for level 3: __try2hackrawks__
Reach to next level 4.

Pete Houston