Trace: » cocoa_basics » c_plus_plus » subversion » javascript » webdev » fink » thesis » git_tutorial

Git

Dreamhost supports git. I just created a git folder to keep my private repositories there. Now git is different from subversion, you don’t have to do an initial check out from remote server and start working on that. What you have to do instead is do your things locally and then push them to the remote server.

Here are the steps considering you already installed git on your Leopard:

git init
git add . 
git commit -a -m "Initial import"
git remote add origin ssh://yourusername@yourserver.com/~/git/IContact.git
[patton]$ cd git
[patton]$ mkdir IContact.git
[patton]$ cd IContact.git/
[patton]$ git --bare init

* now you are ready to push this to remote server.

git push origin master:refs/heads/master

couple of things about the configuration regarding git:

git status

user:IContact user$ git status

git remote add It’s easy to add the remote repo to your remote so that you can access it easily later.

$ git remote add <name> ssh://myserver.com/~/git/IContact.git

then:

$ git push <name> <branch>

git clone

$ git clone ssh://myserver.com/~/git/IContact.git

Commits. Each commit has an author and a committer field, which record who and when created the change and who committed it (Git is designed to work well with patches coming by mail - in that case, the author and the committer will be different). Git will try to guess your realname and email, but especially with email it is likely to get it wrong. You can check it using git config -l and set them with:

git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com

Colors. Git can produce colorful output with some commands; since some people hate colors way more than the rest likes them, by default the colors are turned off. If you would like to have colors in your output:

git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto

Now, one thing specific about xcode, build folders and some unnecessary files that has been changed each time we compile the program and we don’t want to commit those remotely. We don’t need them. So we can use .gitignore to ignore those files when committing.

#Ignore the Mac OS X .DS_Store files
.DS_Store

#Ignore user-specific settings
*.mode1v3
*.mode2v3
*.pbxuser
*.perspectivev3

#Ignore textmate build errors
*.tm_build_errors

#Ignore temp nibs and swap files
*.swp
*~.nib

#Ignore the build, since we don't want archived builds
build

Put this content in a file called .gitignore and place it in the root of $GIT_DIR. If you wish to create a local .gitignore that applies to all your git repositories, place it in ~/ and edit ~/.gitconfig to reference the file

[core]
excludesfile = /Users/yourusername/.gitignore

Git tips

References: