SlideShare ist ein Scribd-Unternehmen logo
1 von 50
Eine praktische Einführung
Marcel Eichner
       @ephigenia

Seit 2000 PHP- & Frontend-
        Entwickler

  Founder und CxO von

    foo(bugs)
Git ([ɡɪt], engl. Blödmann) ist eine freie
Software zur verteilten Versionsverwaltung
von Dateien, die von Linus Torwvalds
ursprünglich für die Quellcode-Verwaltung
des Linux-Kernels entwickelt wurde.
Wieso git?

•   Klein und schnell!
•   Schnelles Branching & Merging
•   Verteilte Repositories (indirekter Backup)
•   Freie, offene Software
•   Daten-Sicherheit durch Content-Hashes

                  http://git-scm.com/about/
Geschwindigkeit

•   (fast) Alle Operationen
    lokal

•   .git Verzeichnis nur auf
    root Ebene

•   http://git-scm.com/
    about/small-and-fast
Eigenschaften
Dezentralität


•   Klon des kompletten Repositories lokal
•   ermöglicht andere Workflows
•   lokales branchen, commiten, reverten etc.
Hashes statt Nummern

•   dezentrale Architektur erlaubt keine
    fortlaufende Revions-Nummerierung
•   Inhalte zählen mehr als Struktur
•   Identifizierung einzelner Commits über
    Content-Hashes (SHA-1)
Nicht-lineare Entwicklung
Rechner 1                            A         B
                                             Branch


                                                           Master
 Remote               1                  2             3   Head

            remote/master (origin)




Rechner 2                      X                   Y
Vier Ebenen
        Remote Repository
                              push
pull
clone
                Local Repository
                              commit


                          Stage
            checkout          add



        Working Directory
Praxis
Konfiguration
Einstellung für Identifikation in git

 $ git config --global user.name "Marcel Eichner"
 $ git config --global user.email "marcel.eichner@foobugs.com"



 # ~/.gitconfig
 [user]
 	    name = Marcel Eichner
 	    email = marcel.eichner@foobugs.com
Repository erstellen
Lokales Repository erstellen

 $ mkdir myrepo
 $ cd myrepo
 $ git init



 Initialized empty Git repository in ../myrepo/.git
Arbeiten ...
$ echo "Hello World" > index.html
git status
Anzeigen aller geänderten und gelöschten Dateien

 $ git status


 # On branch master
 #
 # Initial commit
 #
 # Changes to be committed:
 #    (use "git rm --cached <file>..." to unstage)
 #
 #	    new file:    index.html
 #
 # Changes not staged for commit:
 #    (use "git add <file>..." to update what will be committed)
 #    (use "git checkout -- <file>..." to discard changes in working directory)
 #
 #	    modified:    index.html
Staging
Eine oder mehrere bestimmte Dateien stagen

 $ git add index.html



 $ git add *.html



Alle Änderungen stagen (inklusive gelöschter Dateien)

 $ git add --all
Commit
Änderungen in Stage mit einer Nachricht ins lokale Repo comitten

 $ command
   git commit -m "My first commit"


 [master 7626937] changed
  1 files changed, 1 insertions(+), 1 deletions(-)
Shortcut: Stage & Commit
Alle Änderungen stagen und sofort commiten

 $ git commit -a -m "My Message"


 [master 7626937] changed
  1 files changed, 1 insertions(+), 1 deletions(-)


Letzte Commit-Message editieren

 $ git commit --amend
Remote Repo klonen
git remote repository in den Ordner "mydir" klonen

 $ git clone git@192.168.123.212:testing.git mydir


 Cloning into 'mydir'...
 remote: Counting objects: 3, done.
 remote: Total 3 (delta 0), reused 0 (delta 0)
 Receiving objects: 100% (3/3), done.
Commits hochschieben
Alle commits zum Remote pushen

 $ git push origin master


 # Counting objects: 5, done.
 # Writing objects: 100% (3/3), 272 bytes, done.
 # Total 3 (delta 0), reused 0 (delta 0)
 # To git@192.168.123.212:testing.git
 #   edfec50..2fc284e   master -> master




Allgemeine Syntax

 $ git push [remote-name] [remote-branch-name]
Branching
Branch anlegen und auschecken

 $ git branch my-rad-feature
 $ git checkout my-rad-feature


 Switched to branch 'my-rad-feature'


 $ echo "My Branch is different" > index.html
 $ git commit -a -m "changed content to my branch"
Branches listen
Alle verfügbaren lokalen branches anzeigen

 $ git branch


   master
 * my-rad-feature



Alle verfügbaren branches anzeigen (lokal & remote)

 $ git branch -a


   master
 * my-rad-feature
   remotes/origin/HEAD -> origin/master
   remotes/origin/master
Branch -> Remote
"my-rad-feature"-Branch ins Remote schieben

 $ git push origin my-rad-feature


 Counting objects: 6, done.
 Delta compression using up to 4 threads.
 Compressing objects: 100% (2/2), done.
 Writing objects: 100% (6/6), 482 bytes, done.
 Total 6 (delta 0), reused 0 (delta 0)
 To git@192.168.123.212:testing.git
  * [new branch]      my-rad-feature -> my-rad-feature
Änderungen holen
Alle Änderungen vom Repository holen

 $ git pull


 remote: Counting objects: 7, done.
   remote: Compressing objects: 100% (4/4), done.
   remote: Total 4 (delta 2), reused 0 (delta 0)
   Updating 361303d..f2cd831
   Fast forward
    index.html |    1 +
     1 files changed, 1 insertions(+), 0 deletions(-)
Branch Merging
In den Merge-Ziel-Branch wechseln und mergen

 # assume we are in branch "my-rad-feature" and everything commited
 $ git checkout master


 Switched to branch 'master'


 $ git merge my-rad-feature


 Updating edfec50..2bc1785
 Fast-forward
                                                      Än de r u nge n s in
                                                                           dn
  index.html |    2 +-                                Re mo te S e r ve r. o ch n ich t au f de m
                                                                           Da
  1 files changed, 1 insertions(+), 1 deletions(-)   mus s m a n imm m it s ie do rt la n de n
                                                                         e r n o ch e inm a l
                                                     git push o
                                                                         rigin mast
                                                     aus füh re n !                           er
Wiederherstellen
Gelöschte Datei wieder herstellen

 $ git checkout index.html
git remote
Locales Repository mit dem Remote verbinden

 $ git remote add origin git@192.168.123.212:testing.git
 $ git push origin master


 Counting objects: 3, done.
 Writing objects: 100% (3/3), 231 bytes, done.
 Total 3 (delta 0), reused 0 (delta 0)
 To git@192.168.123.212:testing.git
  * [new branch]      master -> master
weitere nützliche
    Befehle
Log
Log des gesamten Repositories anzeigen

 $ git log


 commit edfec504eb864dc667f3f5b9d301617036d15f3a
 Author: Marcel Eichner <marcel.eichner@foobugs.com>
 Date:   Thu Jun 7 15:37:26 2012 +0200


     My First Commit
Log Extended
Anzeige des Baum-graphen im Log

 $ git log --graph


Filter nach Zeit & Autor

 $ git log --before="2 weeks ago" --after="2012-04-01" --author="Marcel
 Eichner"



Log einer Datei mit Inhalt Merge

 $ git log -p index.html


commit message filter

 $ git log --grep="fixed"
tag
Den aktuellen branch und stand taggen

 $ git tag "release-2012-11-06_12-30-12"


Alle Tags listen

 $ git tag
blame
Blame für eine Datei

 $ git blame index.html


 2fc284e5 (Marcel Eichner 2012-06-07 15:43:47 +0200 1) Hello World it’s me!




Revision Hash


           Committer            Datum der
                                Änderung
Blame zu einem bestimmten Zeitpunkt

 $ git blame index.html [REVISION]
help
$ git [command] --help


NAME
       git-blame - Show what revision and author last modified each line of a file


SYNOPSIS
       git blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w] [--incremental]
[-L n,m]
                   [-S <revs-file>] [-M] [-C] [-C] [-C] [--since=<date>] [--abbrev=<n>]
                   [<rev> | --contents <file> | --reverse <rev>] [--] <file>




DESCRIPTION
       Annotates each line in the given file with information from the revision which last
modified the line. Optionally, start annotating from the given revision.


       The command can also limit the range of lines annotated.
Zwischenablage
Alle Änderungen in die Zwischenablage des lokalen git Repositories schieben

 $ git stash


Änderungen wieder zurückholen

 $ git stash apply


Liste aller Objekte in Zwischenablage

 $ git stash list


Spezifischen Eintrag (2. Eintrag) aus Zwischenablage wieder herstellen

 $ git stash apply stash@{1}
Ignorieren
Projekt-Spezifische ignores

 $ cat .gitignore


 # specific files in all directories
 .DS_Store


 # wildcards
 *.tmp


 # ignore whole directories
 tmp/**/*




globale .gitignore

 $ git config --global core.excludesfile ~/.gitignore
Sub-Modules

• Vergleichbar mit Subversion-
  Externals
• Geklontes Submodule verhält sich
  wie ein eigenes Git Repository
• DRY (Komponenten, Plugins etc.)
Submodul hinzufügen
$ git submodule add https://github.com/jeresig/jquery.hotkeys.git
public/js/vendor/jquery.hotkeys.git



Cloning into 'public/js/vendor/jquery.hotkeys.git'...
remote: Counting objects: 171, done.
remote: Compressing objects: 100% (79/79), done.
remote: Total 171 (delta 104), reused 155 (delta 91)
Receiving objects: 100% (171/171), 170.27 KiB | 204 KiB/s, done.
Resolving deltas: 100% (104/104), done.
Hooks


•   Beispielscripte werden automatisch in
    .git/hooks erstellt
•   Client-Side Post-/Pre-Commit
•   Server-Side Post-/Pre-Push
Hook-Beispiele

•   E-Mail-Notification bei Push
•   IRC / Jabber-Nachrichten bei Push
•   PHPUnit Tests automatisch ausführen
    beim Commit
•   PHPLint Syntax-Check beim Commit
git-svn

•   Subversion Repository mit git nutzen
•   Geschwindigkeit von git für SVN
    repositories
•   Merging, Branching wie man es aus git
    gewohnt ist
Branching-Strategie
http://nvie.com/posts/a-successful-git-branching-model/
Ressourcen
Free Book: http://progit.org
Internet-Hilfe

•   Git-Homepage
    http://git-scm.com
•   Git-Kurs
    http://git.or.cz/course/
•   Every day git
    http://mgorski.net/2011/dev/everyday-git
•   Git Ready
    http://gitready.com/
Tools & SaaS
git gui / gitk
Travis - CI
Fragen?



•   E-Mail: marcel.eichner@foobugs.com
•   Twitter: @ephigenia

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
 
Git Branch
Git BranchGit Branch
Git Branch
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Learning git
Learning gitLearning git
Learning git
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
Git basic
Git basicGit basic
Git basic
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Versionskontrolle mit Git
Versionskontrolle mit GitVersionskontrolle mit Git
Versionskontrolle mit Git
 
Git l'essentiel
Git l'essentielGit l'essentiel
Git l'essentiel
 
Git and Github
Git and GithubGit and Github
Git and Github
 
CI/CD with Github Actions
CI/CD with Github ActionsCI/CD with Github Actions
CI/CD with Github Actions
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 
Git basics
Git basicsGit basics
Git basics
 

Ähnlich wie git - eine praktische Einführung

Git Essentials Cheatsheet Deutsch
Git Essentials Cheatsheet DeutschGit Essentials Cheatsheet Deutsch
Git Essentials Cheatsheet DeutschInfralovers
 
Go - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare SystemeGo - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare SystemeFrank Müller
 
"git.net" gibt's nicht?
"git.net" gibt's nicht?"git.net" gibt's nicht?
"git.net" gibt's nicht?inovex GmbH
 
Childthemes mit git – WordPress MeetUp CGN
Childthemes mit git – WordPress MeetUp CGNChildthemes mit git – WordPress MeetUp CGN
Childthemes mit git – WordPress MeetUp CGNpixolin
 
Sei (k)ein Blödmann und nimm Git!
Sei (k)ein Blödmann und nimm Git!Sei (k)ein Blödmann und nimm Git!
Sei (k)ein Blödmann und nimm Git!Stefan Imhoff
 
OSMC 2018 | Katzeninhalt mit ein wenig Einhornmagie by Carsten Koebke
OSMC 2018 | Katzeninhalt mit ein wenig Einhornmagie by Carsten KoebkeOSMC 2018 | Katzeninhalt mit ein wenig Einhornmagie by Carsten Koebke
OSMC 2018 | Katzeninhalt mit ein wenig Einhornmagie by Carsten KoebkeNETWAYS
 
Introduction to the command line
Introduction to the command lineIntroduction to the command line
Introduction to the command linesteffenbauer
 
Python builds mit ant
Python builds mit antPython builds mit ant
Python builds mit antroskakori
 
Praesentation TYPO3Camp Berlin Speed mit Extbase
Praesentation TYPO3Camp Berlin Speed mit ExtbasePraesentation TYPO3Camp Berlin Speed mit Extbase
Praesentation TYPO3Camp Berlin Speed mit ExtbaseStefan Frömken
 
IPC 2015 Zend Framework 3 Reloaded
IPC 2015 Zend Framework 3 ReloadedIPC 2015 Zend Framework 3 Reloaded
IPC 2015 Zend Framework 3 ReloadedRalf Eggert
 
Einführung Mercurial
Einführung MercurialEinführung Mercurial
Einführung Mercurialwielandp
 
Dokumentation schreiben kann spass machen
Dokumentation schreiben kann spass machenDokumentation schreiben kann spass machen
Dokumentation schreiben kann spass machenSebastian Hempel
 

Ähnlich wie git - eine praktische Einführung (20)

Git
GitGit
Git
 
Git im team
Git im teamGit im team
Git im team
 
git started – IPC2012
git started – IPC2012git started – IPC2012
git started – IPC2012
 
Git Essentials Cheatsheet Deutsch
Git Essentials Cheatsheet DeutschGit Essentials Cheatsheet Deutsch
Git Essentials Cheatsheet Deutsch
 
Version management mit Git und Github
Version management mit Git und Github Version management mit Git und Github
Version management mit Git und Github
 
FLOW3-Workshop F3X12
FLOW3-Workshop F3X12FLOW3-Workshop F3X12
FLOW3-Workshop F3X12
 
Go - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare SystemeGo - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare Systeme
 
"git.net" gibt's nicht?
"git.net" gibt's nicht?"git.net" gibt's nicht?
"git.net" gibt's nicht?
 
GIT / SVN
GIT / SVNGIT / SVN
GIT / SVN
 
Childthemes mit git – WordPress MeetUp CGN
Childthemes mit git – WordPress MeetUp CGNChildthemes mit git – WordPress MeetUp CGN
Childthemes mit git – WordPress MeetUp CGN
 
Einführung in Docker
Einführung in DockerEinführung in Docker
Einführung in Docker
 
git Vorstellung
git Vorstellunggit Vorstellung
git Vorstellung
 
Sei (k)ein Blödmann und nimm Git!
Sei (k)ein Blödmann und nimm Git!Sei (k)ein Blödmann und nimm Git!
Sei (k)ein Blödmann und nimm Git!
 
OSMC 2018 | Katzeninhalt mit ein wenig Einhornmagie by Carsten Koebke
OSMC 2018 | Katzeninhalt mit ein wenig Einhornmagie by Carsten KoebkeOSMC 2018 | Katzeninhalt mit ein wenig Einhornmagie by Carsten Koebke
OSMC 2018 | Katzeninhalt mit ein wenig Einhornmagie by Carsten Koebke
 
Introduction to the command line
Introduction to the command lineIntroduction to the command line
Introduction to the command line
 
Python builds mit ant
Python builds mit antPython builds mit ant
Python builds mit ant
 
Praesentation TYPO3Camp Berlin Speed mit Extbase
Praesentation TYPO3Camp Berlin Speed mit ExtbasePraesentation TYPO3Camp Berlin Speed mit Extbase
Praesentation TYPO3Camp Berlin Speed mit Extbase
 
IPC 2015 Zend Framework 3 Reloaded
IPC 2015 Zend Framework 3 ReloadedIPC 2015 Zend Framework 3 Reloaded
IPC 2015 Zend Framework 3 Reloaded
 
Einführung Mercurial
Einführung MercurialEinführung Mercurial
Einführung Mercurial
 
Dokumentation schreiben kann spass machen
Dokumentation schreiben kann spass machenDokumentation schreiben kann spass machen
Dokumentation schreiben kann spass machen
 

git - eine praktische Einführung

  • 2. Marcel Eichner @ephigenia Seit 2000 PHP- & Frontend- Entwickler Founder und CxO von foo(bugs)
  • 3. Git ([ɡɪt], engl. Blödmann) ist eine freie Software zur verteilten Versionsverwaltung von Dateien, die von Linus Torwvalds ursprünglich für die Quellcode-Verwaltung des Linux-Kernels entwickelt wurde.
  • 4. Wieso git? • Klein und schnell! • Schnelles Branching & Merging • Verteilte Repositories (indirekter Backup) • Freie, offene Software • Daten-Sicherheit durch Content-Hashes http://git-scm.com/about/
  • 5. Geschwindigkeit • (fast) Alle Operationen lokal • .git Verzeichnis nur auf root Ebene • http://git-scm.com/ about/small-and-fast
  • 7. Dezentralität • Klon des kompletten Repositories lokal • ermöglicht andere Workflows • lokales branchen, commiten, reverten etc.
  • 8. Hashes statt Nummern • dezentrale Architektur erlaubt keine fortlaufende Revions-Nummerierung • Inhalte zählen mehr als Struktur • Identifizierung einzelner Commits über Content-Hashes (SHA-1)
  • 9. Nicht-lineare Entwicklung Rechner 1 A B Branch Master Remote 1 2 3 Head remote/master (origin) Rechner 2 X Y
  • 10. Vier Ebenen Remote Repository push pull clone Local Repository commit Stage checkout add Working Directory
  • 12. Konfiguration Einstellung für Identifikation in git $ git config --global user.name "Marcel Eichner" $ git config --global user.email "marcel.eichner@foobugs.com" # ~/.gitconfig [user] name = Marcel Eichner email = marcel.eichner@foobugs.com
  • 13. Repository erstellen Lokales Repository erstellen $ mkdir myrepo $ cd myrepo $ git init Initialized empty Git repository in ../myrepo/.git
  • 14. Arbeiten ... $ echo "Hello World" > index.html
  • 15. git status Anzeigen aller geänderten und gelöschten Dateien $ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: index.html # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: index.html
  • 16. Staging Eine oder mehrere bestimmte Dateien stagen $ git add index.html $ git add *.html Alle Änderungen stagen (inklusive gelöschter Dateien) $ git add --all
  • 17. Commit Änderungen in Stage mit einer Nachricht ins lokale Repo comitten $ command git commit -m "My first commit" [master 7626937] changed 1 files changed, 1 insertions(+), 1 deletions(-)
  • 18. Shortcut: Stage & Commit Alle Änderungen stagen und sofort commiten $ git commit -a -m "My Message" [master 7626937] changed 1 files changed, 1 insertions(+), 1 deletions(-) Letzte Commit-Message editieren $ git commit --amend
  • 19. Remote Repo klonen git remote repository in den Ordner "mydir" klonen $ git clone git@192.168.123.212:testing.git mydir Cloning into 'mydir'... remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), done.
  • 20. Commits hochschieben Alle commits zum Remote pushen $ git push origin master # Counting objects: 5, done. # Writing objects: 100% (3/3), 272 bytes, done. # Total 3 (delta 0), reused 0 (delta 0) # To git@192.168.123.212:testing.git # edfec50..2fc284e master -> master Allgemeine Syntax $ git push [remote-name] [remote-branch-name]
  • 21. Branching Branch anlegen und auschecken $ git branch my-rad-feature $ git checkout my-rad-feature Switched to branch 'my-rad-feature' $ echo "My Branch is different" > index.html $ git commit -a -m "changed content to my branch"
  • 22. Branches listen Alle verfügbaren lokalen branches anzeigen $ git branch master * my-rad-feature Alle verfügbaren branches anzeigen (lokal & remote) $ git branch -a master * my-rad-feature remotes/origin/HEAD -> origin/master remotes/origin/master
  • 23. Branch -> Remote "my-rad-feature"-Branch ins Remote schieben $ git push origin my-rad-feature Counting objects: 6, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (6/6), 482 bytes, done. Total 6 (delta 0), reused 0 (delta 0) To git@192.168.123.212:testing.git * [new branch] my-rad-feature -> my-rad-feature
  • 24. Änderungen holen Alle Änderungen vom Repository holen $ git pull remote: Counting objects: 7, done. remote: Compressing objects: 100% (4/4), done. remote: Total 4 (delta 2), reused 0 (delta 0) Updating 361303d..f2cd831 Fast forward index.html | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
  • 25. Branch Merging In den Merge-Ziel-Branch wechseln und mergen # assume we are in branch "my-rad-feature" and everything commited $ git checkout master Switched to branch 'master' $ git merge my-rad-feature Updating edfec50..2bc1785 Fast-forward Än de r u nge n s in dn index.html | 2 +- Re mo te S e r ve r. o ch n ich t au f de m Da 1 files changed, 1 insertions(+), 1 deletions(-) mus s m a n imm m it s ie do rt la n de n e r n o ch e inm a l git push o rigin mast aus füh re n ! er
  • 26. Wiederherstellen Gelöschte Datei wieder herstellen $ git checkout index.html
  • 27. git remote Locales Repository mit dem Remote verbinden $ git remote add origin git@192.168.123.212:testing.git $ git push origin master Counting objects: 3, done. Writing objects: 100% (3/3), 231 bytes, done. Total 3 (delta 0), reused 0 (delta 0) To git@192.168.123.212:testing.git * [new branch] master -> master
  • 29. Log Log des gesamten Repositories anzeigen $ git log commit edfec504eb864dc667f3f5b9d301617036d15f3a Author: Marcel Eichner <marcel.eichner@foobugs.com> Date: Thu Jun 7 15:37:26 2012 +0200 My First Commit
  • 30. Log Extended Anzeige des Baum-graphen im Log $ git log --graph Filter nach Zeit & Autor $ git log --before="2 weeks ago" --after="2012-04-01" --author="Marcel Eichner" Log einer Datei mit Inhalt Merge $ git log -p index.html commit message filter $ git log --grep="fixed"
  • 31. tag Den aktuellen branch und stand taggen $ git tag "release-2012-11-06_12-30-12" Alle Tags listen $ git tag
  • 32. blame Blame für eine Datei $ git blame index.html 2fc284e5 (Marcel Eichner 2012-06-07 15:43:47 +0200 1) Hello World it’s me! Revision Hash Committer Datum der Änderung Blame zu einem bestimmten Zeitpunkt $ git blame index.html [REVISION]
  • 33. help $ git [command] --help NAME git-blame - Show what revision and author last modified each line of a file SYNOPSIS git blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w] [--incremental] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [-C] [--since=<date>] [--abbrev=<n>] [<rev> | --contents <file> | --reverse <rev>] [--] <file> DESCRIPTION Annotates each line in the given file with information from the revision which last modified the line. Optionally, start annotating from the given revision. The command can also limit the range of lines annotated.
  • 34. Zwischenablage Alle Änderungen in die Zwischenablage des lokalen git Repositories schieben $ git stash Änderungen wieder zurückholen $ git stash apply Liste aller Objekte in Zwischenablage $ git stash list Spezifischen Eintrag (2. Eintrag) aus Zwischenablage wieder herstellen $ git stash apply stash@{1}
  • 35. Ignorieren Projekt-Spezifische ignores $ cat .gitignore # specific files in all directories .DS_Store # wildcards *.tmp # ignore whole directories tmp/**/* globale .gitignore $ git config --global core.excludesfile ~/.gitignore
  • 36. Sub-Modules • Vergleichbar mit Subversion- Externals • Geklontes Submodule verhält sich wie ein eigenes Git Repository • DRY (Komponenten, Plugins etc.)
  • 37. Submodul hinzufügen $ git submodule add https://github.com/jeresig/jquery.hotkeys.git public/js/vendor/jquery.hotkeys.git Cloning into 'public/js/vendor/jquery.hotkeys.git'... remote: Counting objects: 171, done. remote: Compressing objects: 100% (79/79), done. remote: Total 171 (delta 104), reused 155 (delta 91) Receiving objects: 100% (171/171), 170.27 KiB | 204 KiB/s, done. Resolving deltas: 100% (104/104), done.
  • 38. Hooks • Beispielscripte werden automatisch in .git/hooks erstellt • Client-Side Post-/Pre-Commit • Server-Side Post-/Pre-Push
  • 39. Hook-Beispiele • E-Mail-Notification bei Push • IRC / Jabber-Nachrichten bei Push • PHPUnit Tests automatisch ausführen beim Commit • PHPLint Syntax-Check beim Commit
  • 40. git-svn • Subversion Repository mit git nutzen • Geschwindigkeit von git für SVN repositories • Merging, Branching wie man es aus git gewohnt ist
  • 45. Internet-Hilfe • Git-Homepage http://git-scm.com • Git-Kurs http://git.or.cz/course/ • Every day git http://mgorski.net/2011/dev/everyday-git • Git Ready http://gitready.com/
  • 47. git gui / gitk
  • 48.
  • 50. Fragen? • E-Mail: marcel.eichner@foobugs.com • Twitter: @ephigenia