05/4/13

GIT version control

Git Schnellüberblick

https://rogerdudler.github.io/git-guide/index.de.html

Git Book

http://git-scm.com/book/en/

http://git-scm.com/book/de/

GIT – Version control

Proggen.org GIT

Git-Zyklus

git

lokal:

cd mein_projekt
git init

git add .

git commit -m ‘dummy file’
git remote add origin git@mein-git-server.de:mein_projekt.git
git push origin master:refs/heads/master

“your branch is ahead by…” => You need to push to the remote master. Run “git diff origin/master” to see what the differences are between your local repository and the remote master repository.

server:

cd projectroot

git clone /srv/git/repositories/”project”.git/

Lokal: entwicklung

git push origin master

Server:

git pull origin master

Um einen pull rückgängig zu machen:

  git reset HEAD@{1}

Updatezyklus

Commit
$ git commit -m "Initial commit" //speichert lokale Änderungen mit Kommentar "Init...
$ git commit -a -m "Improved xy"  //-a 
$ git log  //zeigt alle lokalen commits mit Kommentaren
$ git status  //Überblick über noch nicht commitette Änderungen am Code
Checkout
hole neuste bzw. letzte eingecheckte Version
$ git checkout -f  //macht die letzten, nichtcommiteten Änderungen rückgängig
$ git status

zeige alle gespeicherten Stände
$ git log
-> liefert alle Stände mit Beschreibunge und id

gehe auf bestimmten Stand
$ git checkout [id]
mache alle Änderungen rückgängig und gehe wieder zum Anfang vom aktuellen checkout
$ git checkout .

gehe zurück zum Master
$ git checkout master
Branch
Erzeugt neuen Branch mit Namen 'modify-README' 
$ git checkout -b modify-README
Switched to a new branch 'modify-README'
$ git branch
Edit
Dateien umbenennen
$ git mv README README.markdown
$ mate README.markdown
$ git rm -r  -filename-
Merge
$ git checkout master
Switched to branch 'master'
$ git merge modify-README

optional: delete topic branch
$ git branch -d modify-README
Global Repository
Iniales Anlegen
$ git remote add origin 
 git@github.com:/sample_app.git //initiales Anlegen eines remote repositories
oder
$ git clone 
 git@github.com:/sample_app.git  //verwende existierendes remote repository
$ gi remote -v  //zeigt alle existierenden remote git-locations an
$ git pull origin master  //holt letzten Stand vom repository
$ git push origin master  //pushed lokalen master branch nach remote
$ git push origin stable   //pushed lokalen stable branch nach remote

Hilfreiche Befehle:

Git log -p -2

p zeigt, was sich verändert hat
2 nur die letzten 2 Änderungen

git log –pretty=oneline
Jeder commit wird nur einzeilig ausgegeben

Autocompletion
http://git-scm.com/book/en/Git-Basics-Tips-and-Tricks

git config –list
Zeige pers. Infos in Konf

Git diff
Um festzustellen, welche Änderungen du bisher nicht gestaged hast

gitk
Grafische Ausgabe von git log

git checkout -b iss53
:=>
$ git branch iss53
$ git checkout iss53

$ git branch -d hotfix
Deleted branch hotfix (3a0874c).

Branches

Branching

Git Datatransport commands

 

Gitolite

Einrichtung-eines-git-servers-unter-debian-via-gitolite

Gitosis (veraltet)

Git Repositories gemeinsam nutzen

Gitosis – the Debian way

Gitosis – auf git.com

Installation im Approot-Verzeichnis (siehe hier)

Deployment

server: edit

nano /srv/git/repositories/gitosis-admin.git/gitosis.conf

enter new project + members:

[group planner]
writable = planner
members = user@email.de