Git – Initialize your Local Git Repository

Rails project works well with Git. A .gitignore file can be found in a freshly created Rails project. It would be good to setup the local Git repository before you start the development.

1. First, install Git

  • apt-get install git-core

 

2. Setup your Git user account.

  • git config –global user.name “Your Name”
  • git config –global user.email youremail@example.com


 

3. Also setup the default text editor for Git.

  • git config –global core.editor “vi”

 

4. Go to your Rails project root directory and add the following ignore paths in the .gitignore file.

# Default ignore paths
.bundle
db/*.sqlite3
log/*.log
tmp/**/*

# Newly added
*.log
tmp/*
doc/api
doc/app
*.swp
*~
.DS_Store

 

5. Initialize the local Git repository.

  • git init

 

6. Go to the Rails project root folder and add all files to the local Git repository.

  • git add .

 

7. Compare the working tree with the repository. There will be many new files which we just added.

  • git status

 

8. Commit all the newly added files.

  • git commit -m “First commit =)”

 

9. Check the status again, there should be nothing to commit. You can also check the commit log by the git log command.

 

Done =)

Reference: Ruby on Rails Tutorial – 1.3 Version control with Git

Advertisement

2 thoughts on “Git – Initialize your Local Git Repository”

  1. I’m not sure if you can help me with this at all. To make a LONG story short: I’m attempting to jailbreak my kindle (3gb wi-fi) & in order to do that I need to set up SSH key access. I have NO knowledge of code & after trying this for 1.5 days (searching the internet for hours & rebooting my kindle too many times to remember) I figured it was time to ask someone who knows about computers (whew!). Anyway, I’m using GitHub (http://help.github.com/win-set-up-git/) & it says failed everytime I try to generate a new SSH key.
    These are some of the codes I’ve tried entering:
    (/Users/CRW/.ssh/id_rsa):
    (/Users/C/Documents and Settings/CRW/My Documents/.ssh/id_rsa):
    (/Users/C/CRW/.ssh/id_rsa):
    Can you PLEASE help me out. . . what am I doing wrong?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.