Thursday, December 9, 2010

Git Basics

There are tons of tutorials out there, I am posting the snippets that i found very useful from this excellent rails tutorial.


  1. Global configurations (these can be seen via the git config --list)
    1. git config --global user.name "Your Name"
    2. git config --global user.email youremail@example.com
    3. git config --global alias.co checkout
    4. git config --global core.editor "mate -w"
  2. Initializing a new project / first time repository setup
    1. git init
  3. Enhanced .gitignore file

    .bundle
    db/*.sqlite3*
    log/*.log
    *.log
    tmp/**/*
    tmp/*
    doc/api
    doc/app
    *.swp
    *~
    .DS_Store

  4. Adding files (this is a recursive command), committing with a message (messages are mandatory), and seeing the log, and the various branches
    1. git add .
    2. git commit -m 'message'
    3. git log
    4. git branch
  5. To see pending commits, checkout, checkout to an existing branch, checkout to a new branch, checkin, merge a branch to the current branch, delete a branch
    1. git status
    2. git checkout
    3. git checkout 'existing branch name'
    4. git checkout -b 'new branch name'
    5. git checkin -a -m'message'
    6. git merge 'branch name'
    7. git branch -d 'branch name'
  6. Adding to github (these commands are displayed when I create a new repo on github)
    1. git remote add origin git@github.com:akil-rails/opac_app.git
    2. git push origin master

No comments:

Post a Comment