Version management mit Git und Github

27

description

fg.workshop vom 03.04.2014 http://fg-informatik.unibas.ch/wiki/index.php/FG-Workshop

Transcript of Version management mit Git und Github

Page 1: Version management mit Git und Github
Page 2: Version management mit Git und Github

  Szenario: Programmier Projekt mit mehreren Beteiligten wird bearbeitet. Alle sollen ◦  die aktuelle Version des Programms haben ◦  über Neuerungen informiert werden

Bestes Vorgehen?

Page 3: Version management mit Git und Github

  Gemeinsame Arbeit am Rechner ?

  Verteilen per Mail oder USB Stick ?

Page 4: Version management mit Git und Github

 Unübersichtlich ◦ Durcheinander von Versionen ◦ Ältere Versionen gehen verloren ◦ Dokumentation geht verloren

Page 5: Version management mit Git und Github

 Nur eine aktuellste Version ◦ Gleichzeitiges Bearbeiten eines Teilstücks

schwierig ◦  Erhöhte Komplexität, wenn mehrere

Personen an verschiedenen Files arbeiten

Page 6: Version management mit Git und Github

 Daten Lokal gespeichert ◦ Datenverlust auf dem Rechner bedeutet auch

Verlust des Programms

Page 7: Version management mit Git und Github
Page 8: Version management mit Git und Github

 Versionierung ◦ Alle alten Versionen vorhanden ◦ Änderungen sichtbar/kommentiert

 Parallele Entwicklung wird unterstützt ◦  Branching/Merging

 Zentrale Ablage ◦  Für alle erreichbar ◦ Absturz des eigenen Rechners verkraftbar

Page 9: Version management mit Git und Github

  Entstehung 2005   Entwickelt von Linus Torvalds   Opensource Alternative zu damals verfügbarer

Software   Einsatz: Entwicklung des Linux Kernels

Page 10: Version management mit Git und Github
Page 11: Version management mit Git und Github

 Github  Atlassian  Community

Page 12: Version management mit Git und Github
Page 13: Version management mit Git und Github

git config --global user.name “John Smith“ git config --global user.email [email protected] git config --global alias.<alias-name> <git-command> git config --system core.editor <editor> git config --global --list

Page 14: Version management mit Git und Github

cd good-project git init git add --all git commit –m “good first comment“ git remote add origin <somePage> git push origin master

Page 15: Version management mit Git und Github

git clone <Repo>

Page 16: Version management mit Git und Github

git pull # Some Work git status git diff git add . git commit –m “Important

Things“ git push

Page 17: Version management mit Git und Github

  git zurücksetzen ◦  rm –r .git

 Alle lokalen Änderungen verwerfen ◦  git reset --hard ◦  git clean -f

Page 18: Version management mit Git und Github

 Letzten commit rückgängig machen ◦  git revert HEAD

 Letzte Änderung an einem File rückgängig machen ◦  git checkout <theFile>

 Commit nachträglich bearbeiten ◦  git add <someFile> ◦  git commit –amend

Page 19: Version management mit Git und Github

  File nicht mehr tracken ◦  .gitignore file ◦  git rm --cached “...“

Page 20: Version management mit Git und Github

 Branch erstellen ◦  git branch <myBranch>

 Branch löschen ◦  git branch –d <myBranch>

 Zu Branch wechseln ◦  git checkout <myBranch>

 Branches anzeigen ◦  git branch

Page 21: Version management mit Git und Github

 branches are just pointers to commits ◦  When you create a branch, all Git needs to do is

create a new pointer—it doesn’t change the repository in any other way. ◦ This has a dramatic impact on Git's merging

model.

Page 22: Version management mit Git und Github

 Whereas merges in SVN are done on a file-basis, Git lets you work on the more abstract level of commits.

 You can actually see merges in the project history as a joining of two independent commit histories.

Page 23: Version management mit Git und Github

# Start a new feature git checkout -b new-feature master # Edit some files git add <file> git commit -m "Start a feature“ # Edit some files git add <file> git commit -m "Finish a feature“ # Merge in the new-feature branch git checkout master git merge new-feature git branch -d new-feature

Page 24: Version management mit Git und Github

# Start a new feature git checkout -b new-feature master # Edit some files git add <file> git commit -m "Start a feature“ # Edit some files git add <file> git commit -m "Finish a feature“

Page 25: Version management mit Git und Github

# Develop the master branch git checkout master # Edit some files git add <file> git commit -m "Make some super-stable

changes to master“ # Merge in the new-feature branch git merge new-feature git branch -d new-feature

Page 26: Version management mit Git und Github

  Studenten Account auf Github: ◦  https://education.github.com

  git Tutorials ◦  http://try.github.io ◦  https://guides.github.com ◦  https://www.atlassian.com/git

  git Docu ◦  http://git-scm.com/documentation

  git Sourcecode ◦  git clone https://github.com/git/git

Page 27: Version management mit Git und Github