Basic Git Command Line on Terminal

Following are some useful command lines for Git operations, running on Mac’s Terminal.

Display Git version.

$ git --version

Initialize Git in a folder. This tells Git that you want to use your the current folder you are in as Git repo

$ git init

Show pending changes (files you have changed and haven’t committed)

$ git status

List all branches

$ git branch

Switch to ‘master’ branch

$ git checkout master

Add remote source named ‘origin’

$ git remote add origin

Download existing branch (‘beta’) from ‘origin’ and save it as ‘beta-test’ branch in local. Local branch can have the same name as the remote branch, this is just to show parameter order.
After fetching from remote, the new branch will NOT have ‘git pull’ tracking configured for that branch. Call ‘branch’ command with ‘–set-upstream-to’ to set tracking information.

git fetch origin beta:beta-test
git checkout beta-test

Set tracking information for local branch called ‘master’ to ‘origin/master’. Must already have the ‘origin/master’ in remote branch.

$ git branch --set-upstream-to=origin/master master

Show remote sources

$ git remote show

Show ‘origin’ info remote source

$ git remote show origin

Look up current configured remote source

$ git remote -v

Pull latest version from ‘origin’ source control after setting remote source

$ git pull origin master

Pull latest version from source control without setting remote source

$ git pull

Add a new file to Git repo

$ git add something.txt

Add all untracked files to Git repo

$ git add .

Remove whole folder and all its content from index (untrack a folder and all its content)

$ git rm foldername -r

Commit to repo with ‘Hello World’ message

$ git commit -m 'Hello World'

Push your commits to the ‘master’ branch of ‘origin’ source to Git

$ git push origin master

Create a local clone of a repository

$ git clone

Fetch from ‘origin’ source

$ git fetch origin

Merge ‘master’ branch of ‘origin’ source to local copy

$ git merge origin/master

Push and track ‘branch1’ to remote ‘origin’. This is for branch that doesn’t yet exist in remote.

$ git push -u origin branch1

Undo (discard) all uncommitted changes.

$ git reset --hard

Undo (discard) all committed (and uncommitted) changes that haven’t been pushed.

$ git reset --hard HEAD~1

To delete a local branch

git branch -d the_local_branch

To remove a remote branch (if you know what you are doing!)

git push origin :the_remote_branch

Create a link (remote) from one repo to another. Git ‘pull’ here is used to download the repo’s branches and tracking information.
See here for more details.

git remote add repo-A-branch <git repository A directory>
git pull repo-A-branch

Cherry pick commit with id 86f4c61 to current branch

$ git cherry-pick 86f4c61

Git Configurations

$ git config

Save git credentials

$ git config credential.helper store
// Can be any command that requires credentials.
$ git push
Username: <type your username>
Password: <type your password>

// Now the credentials are stored and will be used for any command need credentials
$ git push
Level Location Description Command Option
System /etc/gitconfig System level configuration
C:\Program Files\Git
Global .gitconfig
Global level configuration
Local /.git/config Repository level configuration
Local repository folder

Fork vs Clone
Clone doesn’t let you contribute back to the ‘upstream’ repository unless you are explicitly declared as “contributor”. Fork allows you to request a pull from ‘upstream’ repository

Pull vs Fetch
git pull does a git fetch followed by a git merge

Using Wireless Extender (Netgear WiFi Range Extender – WN2000RPT) on AT&T U-verse Router (Windows and Macintosh)

There are tricks in order to use wireless extender on AT&T U-verse router. I am using Netgear Universal WiFi Range Extender (WN2000RPT) for my wireless extender.

Just connecting the extender and complete the extender’s configuration will only give you access to the network, but not the Internet access. This means, you can access the computer within the network, but you can’t access the Internet. This is what I got:

  1. Go to Netgear configuration manager.
  2. Turn off DHCP feature on the extender by going to “IP Address Setup” and use static ip address.
    On “IP Address” field, specify the ip address you want for the extender. Remember this ip address.
    Do note that the “Gateway IP Address” and “Primary DNS” are the ip of your AT&T U-verse router. By default, the AT&T U-verse router’s ip is
  3. Click Apply button to save the setting.
  4. Now, configure your computer’s network setting to point its default gateway and primary dns to the extender’s ip address.
  5. On Windows, open up the network adapter setting.
  6. Display the properties.
  7. Properties on “Internet Protocol Version 4 (TCP/IPv4)” or something similar to that.
  8. Define ip address and dns server address.
    On “IP address”, specify ip address you want for this computer.
    On “Default Gateway” and “Preferred DNS server”, type in the AT&T U-verse router’s ip address. By default, the AT&T U-verse router’s ip is
  9. Go back to network adapter setting to restart the connection (disable and then enable again).

Mac users: you can do the same thing: point your Mac’s network default gateway and dns server address (router) to AT&T U-verse router’s ip address.

To access your network setting, go to System Preferences > Internet & Wireless > Network > Advanced > TCP/IP.

The side effect (not sure if it’s good / bad…) of using this technique is your AT&T U-verse router will assign a ‘dynamic’ ip address for the extender. What I meant by ‘dynamic’ here is, the ip address will constantly change depend on what device is making connection to AT&T U-verse router. So for example, you have specify the extender ip address as in the extender’s configuration manager and you have 2 devices connecting to the extender with ip addresses as and respectively, the extender ip address in AT&T U-verse router will change from, or

Update 4.19.2011: For those who use VMWare Workstation, please read additional post if you have problem connecting the extender to your router: VMWare Workstation and Wireless Network Adapter Problem.

Access iPad File System with SSH from Mac

  1. Install “OpenSSH” on your iPad This can be found on Cydia if the iPad is jail-broken.
  2. Enable the SSH connection on the iPad I install “SBSettings” from Cydia to turn SSH on / off. There are many other apps that can do this.
  3. Find out your iPad’s IP address If you have “SBSettings” installed, you can see your IP address on this app as well.
  4. From your mac, run Terminal
  5. SSH to your iPad by typing the following command SSH root@
  6. When prompted for Password, type in “alpine” (without double quote – all lowercase)
  7. Whoola, you are in iPad’s file system now.
  8. If you can’t access your iPad with SSH, try reboot the iPad.

Delete All iPad’s Address Book and Calendar Data

  1. SSH to your iPad.
  2. Note that the folder and file names in iPad are case-sensitive.
  3. Delete “AddressBook.sqlitedb” file on “/private/var/mobile/Library/AddressBook/” with the following command:
    rm /private/var/mobile/Library/AddressBook/AddressBook.sqlitedb
  4. Delete “Calendar.sqlitedb” file on “/private/var/mobile/Library/Calendar/” with the following command:
    rm /private/var/mobile/Library/Calendar/Calendar.sqlitedb

How to Capture Screenshot on Mac OS X

  1. Command + Shift + 3
    Capture whole screen and save the file on desktop
  2. Command + Control + Shift + 3
    Capture whole screen and save to clipboard
  3. Command + Shift + 4
    Capture specific area (with cross-hair cursor) and save the file on desktop
  4. Command + Control + Shift + 4
    Capture specific area (with cross-hair cursor) and save to clipboard
  5. Command + Shift + 4. Then Space.
    Capture specific window and save the file on desktop
  6. Command + Control + Shift + 4. Then Space.
    Capture specific window and save to clipboard