November 27 2008, 7am
No Comments

Every time, once you create a new Rails application on a Git resipotary, you have to create a .gitignore file to make sure that Git will ignore certain files that it should not keep track. For examples,

log/*.log
tmp/**/*
.DS_Store
doc/api
doc/app

These are the static and dynamic files that Rails creates. So, I create a simple ruby script into my bin directory so that I can just use a simple command to create this .gitignore file easily.

Firstly, in terminal, under your home directory, change your directory into “bin” subdirectory. Create a text file called “gitignore”. Inside the file, use your favorite text editor, write:

#!/usr/bin/env ruby
# create .gitignore

f = File.new(".gitignore", "w")
f.write("log/*.log\n")
f.write("tmp/**/*\n")
f.write(".DS_Store\n")
f.write("doc/api\n")
f.write("doc/app\n")
f.close

puts ".gitignore created."

Save the file and close your text editor. Then, chmod the “gitignore” file:

chmod a+x gitignore

So, now, every time, after you create a Rails application with the “rails” command, change directory into your Rails application’s directory, fire the “gitignore” command, the .gitignore file will be created automatically.

Happy Gitting.

October 9 2008, 10pm
No Comments

If you are hardcore Textmate user, you may feel annoyed everytime when you fire the “git commit -a” command. The default editor used by Git is Vim. By applying a small change, you can change the default editor to Textmate instead of Vim.

In Terminal, type:

git config core.editor "mate -w"

Now, you are done. You have changed the default editor in Git to Textmate. Besides that, you can in fact use this command:

git commit -a -m "Hi I am a hardcore Textmate user."

This command will automatically add the new commit message “Hi I am a hardcore Textmate user.” to your new commit instead of firing up an editor to write your commit message.

Happy Gitting!