Git is a distributed software configuration management tool that has been adopted by the majority of the Ruby on Rails community. In many cases, Git is required for plugin installation.
See instructions on how to install Git for your platform.
In order to take advantage of Git, you must first create a Git repository.
$ cd your_rails_application $ git init
To work with an existing repository, you need to clone it to your local work station.
$ cd ~ $ git clone protocol://user@host:/path/to/repository
For example, to clone the Ruby on Rails Git repository from Github, use the following
$ git clone git://github.com/rails/rails.git
After you have made changes in your project and are confident in the revision, it is time to commit those changes.
$ git add . $ git commit -m 'Initial Commit'
Branching is essentially making a working copy of the source, or master branch, so you can modify it and test those changes without fear of altering the master branch. Once the changes have been tested and approved, they may be merged into the master branch.
Check what branches already exist.
$ git branch * master
Since there is only a master branch, we will add a new branch.
$ git branch testing
$ git branch
* master
testing
Switch to the newly created testing branch.
$ git checkout testing Switched to branch "testing"
After you have finished working on your new branch, it is time to commit it to the testing branch.
$ git add . $ git commit -m 'added great new feature'
Switch to the master branch and merge with the testing branch.
$ git checkout master $ git merge testing
The changes you made to the testing branch have now been merged into the master branch.
Let's delete the testing branch now that it is no longer needed.
$ git branch -d testing Deleted branch testing
Discussion