Version management mit Git und Github
-
Upload
fginformatik-universitaet-basel -
Category
Internet
-
view
189 -
download
2
description
Transcript of 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?
Gemeinsame Arbeit am Rechner ?
Verteilen per Mail oder USB Stick ?
Unübersichtlich ◦ Durcheinander von Versionen ◦ Ältere Versionen gehen verloren ◦ Dokumentation geht verloren
Nur eine aktuellste Version ◦ Gleichzeitiges Bearbeiten eines Teilstücks
schwierig ◦ Erhöhte Komplexität, wenn mehrere
Personen an verschiedenen Files arbeiten
Daten Lokal gespeichert ◦ Datenverlust auf dem Rechner bedeutet auch
Verlust des Programms
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
Entstehung 2005 Entwickelt von Linus Torvalds Opensource Alternative zu damals verfügbarer
Software Einsatz: Entwicklung des Linux Kernels
Github Atlassian Community
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
cd good-project git init git add --all git commit –m “good first comment“ git remote add origin <somePage> git push origin master
git clone <Repo>
git pull # Some Work git status git diff git add . git commit –m “Important
Things“ git push
git zurücksetzen ◦ rm –r .git
Alle lokalen Änderungen verwerfen ◦ git reset --hard ◦ git clean -f
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
File nicht mehr tracken ◦ .gitignore file ◦ git rm --cached “...“
Branch erstellen ◦ git branch <myBranch>
Branch löschen ◦ git branch –d <myBranch>
Zu Branch wechseln ◦ git checkout <myBranch>
Branches anzeigen ◦ git branch
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.
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.
# 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
# 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“
# 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
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