Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
Universität Hamburg
MIN-FakultätDepartment Informatik
Git Version Control System
Introduction to the Git Version Control System
Sebastian [email protected]
University of HamburgFaculty of Mathematics, Informatics and Natural Sciences
Department of InformaticsTechnical Aspects of Multimodal Systems
November 8, 2011S. Rockel 1
Universität Hamburg
MIN-FakultätDepartment Informatik
Git Version Control System
OutlineIntroductionConfiguration
User SetupRepository Setup
Basic TasksCommonly used CommandsBranches
Special UsecasesGUITagsRemote Repositories
S. Rockel 2
Universität Hamburg
MIN-FakultätDepartment Informatik
Introduction Git Version Control System
IntroductionGit is..
I from Linus Torwalds
I local (and remote if necessary)
I fast (well..)
I Comprehensiv Howto @ http://linux.yyz.us/git-howto.html
S. Rockel 3
Universität Hamburg
MIN-FakultätDepartment Informatik
Introduction Git Version Control System
IntroductionGit is..
I from Linus Torwalds
I local (and remote if necessary)
I fast (well..)
I Comprehensiv Howto @ http://linux.yyz.us/git-howto.html
S. Rockel 3
Universität Hamburg
MIN-FakultätDepartment Informatik
Introduction Git Version Control System
IntroductionGit is..
I from Linus Torwalds
I local (and remote if necessary)
I fast (well..)
I Comprehensiv Howto @ http://linux.yyz.us/git-howto.html
S. Rockel 3
Universität Hamburg
MIN-FakultätDepartment Informatik
Introduction Git Version Control System
IntroductionGit is..
I from Linus Torwalds
I local (and remote if necessary)
I fast (well..)
I Comprehensiv Howto @ http://linux.yyz.us/git-howto.html
S. Rockel 3
Universität Hamburg
MIN-FakultätDepartment Informatik
Introduction Git Version Control System
Insights
I IndexI under:� �<r epos i to ry d i r >/. g i t / . .� �
I HashesI every version in the index has its own unique SHA1 hashI abbreviate it with the first few character
S. Rockel 4
Universität Hamburg
MIN-FakultätDepartment Informatik
Introduction Git Version Control System
Insights
I IndexI under:� �<r epos i to ry d i r >/. g i t / . .� �
I HashesI every version in the index has its own unique SHA1 hashI abbreviate it with the first few character
S. Rockel 4
Universität Hamburg
MIN-FakultätDepartment Informatik
Configuration - User Setup Git Version Control System
OutlineIntroductionConfiguration
User SetupRepository Setup
Basic TasksCommonly used CommandsBranches
Special UsecasesGUITagsRemote Repositories
S. Rockel 5
Universität Hamburg
MIN-FakultätDepartment Informatik
Configuration - User Setup Git Version Control System
Git per User Setup$HOME/.gitconfig� �
1 [ gui ]recentrepo = / Users / sebas t i an / projekt090406
3 s p e l l i n g d i c t i o n a r y = en[ user ]
5 emai l = rocke l@ in fo rmat ik . uni−hamburg . dename = Sebast ian Rockel
7 [ merge ]t o o l = open d i f f
9 summary = t rue[ c o l o r ]
11 d i f f = autos ta tus = auto
13 branch = auto[ core ]
15 a u t o c r l f = i nput� �S. Rockel 6
Universität Hamburg
MIN-FakultätDepartment Informatik
Configuration - Repository Setup Git Version Control System
OutlineIntroductionConfiguration
User SetupRepository Setup
Basic TasksCommonly used CommandsBranches
Special UsecasesGUITagsRemote Repositories
S. Rockel 7
Universität Hamburg
MIN-FakultätDepartment Informatik
Configuration - Repository Setup Git Version Control System
Exclude Files
per repo: <repository dir>/.git/info/exclude� �# L ines that s t a r t with ’# ’ are comments .# For a p r o j e c t mostly i n C , the f o l l o w i n g# would be a good set of exc lude patte rns# (uncomment them i f you want to use them ) :# ∗ . [ oa ]∗~∗ . swp� �per (sub)dir: <some repo (sub) dir>/.gitignore� �. metadata//doc/� �
S. Rockel 8
Universität Hamburg
MIN-FakultätDepartment Informatik
Configuration - Repository Setup Git Version Control System
Exclude Files
per repo: <repository dir>/.git/info/exclude� �# L ines that s t a r t with ’# ’ are comments .# For a p r o j e c t mostly i n C , the f o l l o w i n g# would be a good set of exc lude patte rns# (uncomment them i f you want to use them ) :# ∗ . [ oa ]∗~∗ . swp� �per (sub)dir: <some repo (sub) dir>/.gitignore� �. metadata//doc/� �
S. Rockel 8
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Commonly used Commands Git Version Control System
OutlineIntroductionConfiguration
User SetupRepository Setup
Basic TasksCommonly used CommandsBranches
Special UsecasesGUITagsRemote Repositories
S. Rockel 9
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Commonly used Commands Git Version Control System
Basic Tasks
clone a remote repository:� �g i t c lone
git@github .com : buzzer/Robot−Col laborat ion . g i t� �get the latest changes from remote repo:� �g i t fetch [ $branch|−− a l l ]� �� �g i t p u l l [ opt iona l ssh/https path again ]� �
S. Rockel 10
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Commonly used Commands Git Version Control System
Basic Tasks
clone a remote repository:� �g i t c lone
git@github .com : buzzer/Robot−Col laborat ion . g i t� �get the latest changes from remote repo:� �g i t fetch [ $branch|−− a l l ]� �� �g i t p u l l [ opt iona l ssh/https path again ]� �
S. Rockel 10
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Commonly used Commands Git Version Control System
Basic Tasks (cont’d)
stage changes for commit:� �g i t add . |− i | $ f i l e s� �commit changes:� �g i t commit −a|−m ’message ’� �revert version, checkout:� �g i t checkout [− f ] . | $branch | $hash� �
S. Rockel 11
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Commonly used Commands Git Version Control System
Basic Tasks (cont’d)
stage changes for commit:� �g i t add . |− i | $ f i l e s� �commit changes:� �g i t commit −a|−m ’message ’� �revert version, checkout:� �g i t checkout [− f ] . | $branch | $hash� �
S. Rockel 11
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Commonly used Commands Git Version Control System
Basic Tasks (cont’d)
stage changes for commit:� �g i t add . |− i | $ f i l e s� �commit changes:� �g i t commit −a|−m ’message ’� �revert version, checkout:� �g i t checkout [− f ] . | $branch | $hash� �
S. Rockel 11
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Commonly used Commands Git Version Control System
Basic Tasks (cont’d)Get the current repo status
Show current branch, changes, untracked files:� �g i t s tatus� �Show commit history:� �g i t log� �Show textual diff of current changes:� �g i t d i f f� �
S. Rockel 12
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Commonly used Commands Git Version Control System
Basic Tasks (cont’d)Get the current repo status
Show current branch, changes, untracked files:� �g i t s tatus� �Show commit history:� �g i t log� �Show textual diff of current changes:� �g i t d i f f� �
S. Rockel 12
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Commonly used Commands Git Version Control System
Basic Tasks (cont’d)Get the current repo status
Show current branch, changes, untracked files:� �g i t s tatus� �Show commit history:� �g i t log� �Show textual diff of current changes:� �g i t d i f f� �
S. Rockel 12
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Branches Git Version Control System
OutlineIntroductionConfiguration
User SetupRepository Setup
Basic TasksCommonly used CommandsBranches
Special UsecasesGUITagsRemote Repositories
S. Rockel 13
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Branches Git Version Control System
Branchesthere might be life besides the master
List available branches� �g i t branch [−a ]� �Create a new branch� �g i t branch $newbranch� �Switch to a new branch� �g i t checkout $newbranch� �
S. Rockel 14
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Branches Git Version Control System
Branchesthere might be life besides the master
List available branches� �g i t branch [−a ]� �Create a new branch� �g i t branch $newbranch� �Switch to a new branch� �g i t checkout $newbranch� �
S. Rockel 14
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Branches Git Version Control System
Branchesthere might be life besides the master
List available branches� �g i t branch [−a ]� �Create a new branch� �g i t branch $newbranch� �Switch to a new branch� �g i t checkout $newbranch� �
S. Rockel 14
Universität Hamburg
MIN-FakultätDepartment Informatik
Basic Tasks - Branches Git Version Control System
Branches (cont’d)
Delete a branch� �g i t branch −d|−D $newbranch� �
S. Rockel 15
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - GUI Git Version Control System
OutlineIntroductionConfiguration
User SetupRepository Setup
Basic TasksCommonly used CommandsBranches
Special UsecasesGUITagsRemote Repositories
S. Rockel 16
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - GUI Git Version Control System
Guinot needed but nice to have� �
g i t fetch [ $branch|−− a l l ]� �Display changes, prepare, execute commit� �g i t gui� �Show all commits, branches� �g i tk [−− a l l ]� �
S. Rockel 17
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - GUI Git Version Control System
Guinot needed but nice to have� �
g i t fetch [ $branch|−− a l l ]� �Display changes, prepare, execute commit� �g i t gui� �Show all commits, branches� �g i tk [−− a l l ]� �
S. Rockel 17
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - GUI Git Version Control System
Merge Tool
I normally not neededI Git automatic merge is quite efficientI if there are merge conflicts, a (system dependent, see Git
config) merge tool can be used:� �g i t mergetool� �
S. Rockel 18
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - GUI Git Version Control System
Merge Branches
I Master branch MI Work branch A and BI merge A and B into M� �
g i t checkout M # switch to branch Mg i t merge A # merge A into Mg i t merge B # merge B into M� �
S. Rockel 19
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - Tags Git Version Control System
OutlineIntroductionConfiguration
User SetupRepository Setup
Basic TasksCommonly used CommandsBranches
Special UsecasesGUITagsRemote Repositories
S. Rockel 20
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - Tags Git Version Control System
Don’t forget the tags
I tag versions� �g i t tag v1 . 3� �I git pull / push does not take tags into account� �
g i t p u l l | fetch −−tagsg i t push −−tags� �
S. Rockel 21
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - Tags Git Version Control System
Don’t forget the tags
I tag versions� �g i t tag v1 . 3� �I git pull / push does not take tags into account� �
g i t p u l l | fetch −−tagsg i t push −−tags� �
S. Rockel 21
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - Remote Repositories Git Version Control System
OutlineIntroductionConfiguration
User SetupRepository Setup
Basic TasksCommonly used CommandsBranches
Special UsecasesGUITagsRemote Repositories
S. Rockel 22
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - Remote Repositories Git Version Control System
Github
https://github.com
add remote repo� �g i t remote add o r i g i n $remoteRepo� �
S. Rockel 23
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - Remote Repositories Git Version Control System
Github
https://github.com
add remote repo� �g i t remote add o r i g i n $remoteRepo� �
S. Rockel 23
Universität Hamburg
MIN-FakultätDepartment Informatik
Special Usecases - Remote Repositories Git Version Control System
SVN
I Working with a remote Subversion repository (but with gitlocally)� �
git −svn clone [ http locat ion of an svn repos i to ry ]� �I Now you can work with the checked out directory as though it
was a git repository
S. Rockel 24
Universität Hamburg
MIN-FakultätDepartment Informatik
Appendix Git Version Control System
Thank You!
Any questions?
S. Rockel 25
Universität Hamburg
MIN-FakultätDepartment Informatik
Appendix - Further Reading Git Version Control System
Further Reading
I http://linux.yyz.us/git-howto.htmlI http://help.github.com/git-cheat-sheets
S. Rockel 26