Inhaltsverzeichnis

Versionskontrolle mit Git

Git ist ein verteiltes software konfigurationsmanagement tool, das mittlerweile von der Mehrheit der Ruby on Rails Community hauptsächlich eingesetzt wird. In vielen Fällen ist Git Voraussetzung um ein Plugin von der Kommandozeile zu installieren.

Git installieren

OSX

Es existiert ein vorgebautes OSX Paket der neuesten Version:

http://code.google.com/p/git-osx-installer/downloads/list?can=3

Ubuntu 8.04/8.10

Vom Repository

Die einfachste Methode ist apt-get zu benutzen um Git zu installieren.

$ sudo apt-get update
$ sudo apt-get install git-core

Vom Quellcode

Man kann auch direkt vom Sourcecode installieren, da die Repositories ein wenig hinterhinken (wahrscheinlich weil Git zur Zeit sehr angesagt ist und fieberhaft weiterentwickelt wird).

Wenn noch nicht bereits geschehen, erstelle ein Verzeichnis wo die Git Quelldateien heruntergeladen werden sollen. Der momentane Source ist verfügbar unter: http://git-scm.com/download

$ mkdir sources
$ cd sources
$ wget [URL der momentanten Version hier einfügen]

Nachdem Git heruntergeladen wurde, muss es entpackt, gebaut und installiert werden. Dafür genügen glücklicherweise ein paar einfache Befehle:

$ tar xjvf git-[neueste versionsnummer]
$ cd git-[neueste versionsnummer]
$ sudo apt-get build-dep git-core
$ ./configure
$ make
$ sudo make install

Man beachte die Zeile sudo apt-get build-dep git-core, dies installiert die benötigten Dateien um Git zu bauen.

TODO: Continue Translation

CentOS 5

Fedora's EPEL software repository needs to be added to install Git with Yum.

$ su
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
# yum install git

Microsoft Windows

msysgit is a Windows Git installer.

TortoiseGit is a port of TortoiseSVN for Git.

Basic Usage

Creating a Repository

In order to take advantage of Git, you must first create a Git repository.

$ cd your_rails_application
$ git init

Cloning a Repository

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

Commiting Changes

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 and Merging

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

Additional Resources