Sunday, January 04, 2009

Project setup using GitHub

Just taking notes on how to setup project in GitHub. These notes are from GitCasts and GitHub Guides.

1. Setup, Initialization and Cloning

Global setup, these apply to all projects on the system:

git config --global 'User Name'
git config --global
git config --global color.status auto
git config --global color.branch auto
git config --global core.autocrlf true

To save project in git repository:
1. First, create the project.
2. cd to the project, then do the following:

git init
git add .
git ls-files --cache
git commit -m "Initial Commit"
git status
git log

To clone existing code in the git repo:

git clone git://

If it's your own repo, use this instead:

git clone 

2. Normal Workflow

Create .gitignore file, this is to specify which files we don't want to add to git, like as follows:


Editing files and commiting to repo:

git status
git add [filename]
git commit
git commit -a -m 'My Next Commit' #automatically add and commit all changed files
git ls-files --stage
git rm public/robots.txt #remove a file, git not to track the file anymore
git status
git commit -m 'robots file removed'

Now push to remote repo:

git remote add origin
git push origin master

Take note that if you get the error message:

fatal: protocol error: expected sha/ref

You need to make sure that .git/config [remote "origin"] url entry is in the form of

When working on another machine, to get latest changes:

git pull