Saturday, December 29, 2012

Install Git and GitHub for snow leopard

I have a snow leopard laptop. 

From, it automatically downloaded  "git-". Double-click this file generated a "Git Snow Leopard Intel Universal" disk, which contains four files: 1), 2) README, 3) 'setup git PATH for non-terminal, 4) git- After running the fourth file, a successful install message occurred. 

I then found out that the free GUI for Git, GitHub, has stopped support for snow leopard. This leaves me the only option to follow the command-line version on

$ git config --global "hongqin"
$ git config --global ""
$ curl -s -O \
$ chmod u+x git-credential-osxkeychain 
$ cd /opt/local/bin   #I saw osxkeychain already here
$ git config --global credential.helper osxkeychain

By now, I have finished all the steps on  

I then proceed to created a 'Public' repository, named "sandbox". I chose a README option.  After hitting the green "create repository" button, a new page appeared in about one second.

When I clicked "Clone in Mac", it took me back to GitHub Mac version for 10.7+. When I clicked "ZIP", it started download "" into local Download. This zip file contains the file and the sandbox-master directory structure.  I then noticed that I was in the 'branch:master' mode. 

To test how GitHub works locally, I created a hello world file in local sandbox-master. 

$cd sandbox-master
$git init
Initialized empty Git repository in /Users/hongqin/github/sandbox-master/.git/

$ git add helloworld.txt
$ git commit -m "first local commit"
[master (root-commit) 6654d46] first local commit
 1 file changed, 1 insertion(+)
 create mode 100644 helloword.txt

$ git remote add origin
$ git push origin master
Username for '': hongqin
Password for '':
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to ''
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

This non-fast-forward error seems to be a common error:

$ git push --force origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 230 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
 + c8d6cad...6654d46 master -> master (forced update)

I then refreshed GitHub sandbox web page, and found "helloworld.txt" there. But "" disappeared.This may explain my 'non-fast-forward error'.

$ git add README.txt
$ git commit -m "second local commit"

[master bdcefa8] second local commit
 1 file changed, 2 insertions(+)
 create mode 100644 README.txt

$ git remote add origin
fatal: remote origin already exists.
$ git push origin master
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 288 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
   6654d46..bdcefa8  master -> master
I  then refreshed my GitHub webpage and see both files. 

Oddly, there is still "" file, but I do not see this file in the downloaed ZIP archive.  I leave it for now. 

No comments:

Post a Comment