Introduction to the Sebastian Rockel rockel@informatik.uni-hamburg.de University of Hamburg Faculty of Mathematics, Informatics and Natural Sciences Department of Informatics Technical Aspects of Multimodal Systems November 8, 2011 S. Rockel 1
Outline Introduction Configuration User Setup Repository Setup Basic Tasks Commonly used Commands Branches Special Usecases GUI Tags Remote Repositories S. Rockel 2
Introduction Universität Hamburg Introduction Git is.. from Linus Torwalds local (and remote if necessary) fast (well..) Comprehensiv Howto @ http://linux.yyz.us/git-howto.html S. Rockel 3
Introduction Universität Hamburg Introduction Git is.. from Linus Torwalds local (and remote if necessary) fast (well..) Comprehensiv Howto @ http://linux.yyz.us/git-howto.html S. Rockel 3
Introduction Universität Hamburg Introduction Git is.. from Linus Torwalds local (and remote if necessary) fast (well..) Comprehensiv Howto @ http://linux.yyz.us/git-howto.html S. Rockel 3
Introduction Universität Hamburg Introduction Git is.. from Linus Torwalds local (and remote if necessary) fast (well..) Comprehensiv Howto @ http://linux.yyz.us/git-howto.html S. Rockel 3
Introduction Universität Hamburg Insights Index under: <r e p o s i t o r y dir >/. g i t /.. Hashes every version in the index has its own unique SHA1 hash abbreviate it with the first few character S. Rockel 4
Introduction Universität Hamburg Insights Index under: <r e p o s i t o r y dir >/. g i t /.. Hashes every version in the index has its own unique SHA1 hash abbreviate it with the first few character S. Rockel 4
Configuration - User Setup Outline Introduction Configuration User Setup Repository Setup Basic Tasks Commonly used Commands Branches Special Usecases GUI Tags Remote Repositories S. Rockel 5
Configuration - User Setup Git per User Setup $HOME/.gitconfig 1 [ gui ] recentrepo = / Users / s e b a s t i a n / projekt090406 3 s p e l l i n g d i c t i o n a r y = en [ user ] 5 email = r o c k e l @ i n f o r m a t i k. uni hamburg. de name = Sebastian Rockel 7 [ merge ] t o o l = o p e n d i f f 9 summary = true [ c o l o r ] 11 d i f f = auto s t a t u s = auto 13 branch = auto [ core ] 15 a u t o c r l f = input S. Rockel 6
Configuration - Repository Setup Outline Introduction Configuration User Setup Repository Setup Basic Tasks Commonly used Commands Branches Special Usecases GUI Tags Remote Repositories S. Rockel 7
Configuration - Repository Setup Exclude Files per repo: <repository dir>/.git/info/exclude # L i n e s 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 s e t of exclude p a t t e r n s # ( uncomment them i f you want to use them ) : #. [ oa ] ~. swp per (sub)dir: <some repo (sub) dir>/.gitignore. metadata/ /doc/ S. Rockel 8
Configuration - Repository Setup Exclude Files per repo: <repository dir>/.git/info/exclude # L i n e s 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 s e t of exclude p a t t e r n s # ( uncomment them i f you want to use them ) : #. [ oa ] ~. swp per (sub)dir: <some repo (sub) dir>/.gitignore. metadata/ /doc/ S. Rockel 8
Basic Tasks - Commonly used Commands Outline Introduction Configuration User Setup Repository Setup Basic Tasks Commonly used Commands Branches Special Usecases GUI Tags Remote Repositories S. Rockel 9
Basic Tasks - Commonly used Commands Basic Tasks clone a remote repository: g i t clone git@github. com : buzzer /Robot Collaboration. 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 [ o p t i o n a l ssh / https path again ] S. Rockel 10
Basic Tasks - Commonly used Commands Basic Tasks clone a remote repository: g i t clone git@github. com : buzzer /Robot Collaboration. 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 [ o p t i o n a l ssh / https path again ] S. Rockel 10
Basic Tasks - Commonly used Commands 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
Basic Tasks - Commonly used Commands 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
Basic Tasks - Commonly used Commands 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
Basic Tasks - Commonly used Commands Basic Tasks (cont d) Get the current repo status Show current branch, changes, untracked files: g i t status Show commit history: g i t log Show textual diff of current changes: g i t d i f f S. Rockel 12
Basic Tasks - Commonly used Commands Basic Tasks (cont d) Get the current repo status Show current branch, changes, untracked files: g i t status Show commit history: g i t log Show textual diff of current changes: g i t d i f f S. Rockel 12
Basic Tasks - Commonly used Commands Basic Tasks (cont d) Get the current repo status Show current branch, changes, untracked files: g i t status Show commit history: g i t log Show textual diff of current changes: g i t d i f f S. Rockel 12
Basic Tasks - Branches Outline Introduction Configuration User Setup Repository Setup Basic Tasks Commonly used Commands Branches Special Usecases GUI Tags Remote Repositories S. Rockel 13
Basic Tasks - Branches Branches there 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
Basic Tasks - Branches Branches there 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
Basic Tasks - Branches Branches there 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
Basic Tasks - Branches Branches (cont d) Delete a branch g i t branch d D $newbranch S. Rockel 15
Special Usecases - GUI Outline Introduction Configuration User Setup Repository Setup Basic Tasks Commonly used Commands Branches Special Usecases GUI Tags Remote Repositories S. Rockel 16
Special Usecases - GUI Gui not 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 t k [ a l l ] S. Rockel 17
Special Usecases - GUI Gui not 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 t k [ a l l ] S. Rockel 17
Special Usecases - GUI Merge Tool normally not needed Git automatic merge is quite efficient if there are merge conflicts, a (system dependent, see Git config) merge tool can be used: g i t mergetool S. Rockel 18
Special Usecases - GUI Merge Branches Master branch M Work branch A and B merge A and B into M g i t checkout M # switch to branch M g i t merge A # merge A i n t o M g i t merge B # merge B i n t o M S. Rockel 19
Special Usecases - Tags Outline Introduction Configuration User Setup Repository Setup Basic Tasks Commonly used Commands Branches Special Usecases GUI Tags Remote Repositories S. Rockel 20
Special Usecases - Tags Don t forget the tags tag versions g i t tag v1. 3 git pull / push does not take tags into account g i t g i t p u l l fetch tags push tags S. Rockel 21
Special Usecases - Tags Don t forget the tags tag versions g i t tag v1. 3 git pull / push does not take tags into account g i t g i t p u l l fetch tags push tags S. Rockel 21
Special Usecases - Remote Repositories Outline Introduction Configuration User Setup Repository Setup Basic Tasks Commonly used Commands Branches Special Usecases GUI Tags Remote Repositories S. Rockel 22
Special Usecases - Remote Repositories Github https://github.com add remote repo g i t remote add o r i g i n $remoterepo S. Rockel 23
Special Usecases - Remote Repositories Github https://github.com add remote repo g i t remote add o r i g i n $remoterepo S. Rockel 23
Special Usecases - Remote Repositories SVN Working with a remote Subversion repository (but with git locally) git svn clone [ http l o c a t i o n of an svn r e p o s i t o r y ] Now you can work with the checked out directory as though it was a git repository S. Rockel 24
Appendix Universität Hamburg Thank You! Any questions? S. Rockel 25
Appendix - Further Reading Further Reading http://linux.yyz.us/git-howto.html http://help.github.com/git-cheat-sheets S. Rockel 26