git-12613901533412-phpapp02
TRANSCRIPT
-
8/7/2019 git-12613901533412-phpapp02
1/58
Clickicontoaddpicture
Clickicontoaddpicture
Git
The fast version control system
Jeroen [email protected]
m
-
8/7/2019 git-12613901533412-phpapp02
2/58
Table of contents
Short introduction to version control
Version control systems
Comparison with subversionDistributed version control
Git usage
Basic operations
Solving conflicts
Branching as a core concept
Tooling
Conclusion
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
3/58
Version control
Short introduction
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
4/58
Version control (1)
The management of changes todocuments, programs, and otherinformation stored as computer files
A system that maintains versions of filesat progressive stages of development.
Every file
Has a full history of changes
Can be restored to any version
A communication tool, like email, butwith code rather than humanconversation
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
5/58
Version control (2)
Benefits
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
6/58
Version control (2)
Benefits
Allows a team to share code
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
7/58
Version control (2)
Benefits
Allows a team to share code
Maintains separate production versionsof code that are always deployable
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
8/58
Version control (2)
Benefits
Allows a team to share code
Maintains separate production versionsof code that are always deployable
Allows simultaneous development ofdifferent features on the same codebase
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
9/58
Version control (2)
Benefits
Allows a team to share code
Maintains separate production versionsof code that are always deployable
Allows simultaneous development ofdifferent features on the same codebase
Keeps track of all old versions of files
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
10/58
Version control (2)
Benefits
Allows a team to share code
Maintains separate production versionsof code that are always deployable
Allows simultaneous development ofdifferent features on the same codebase
Keeps track of all old versions of files
Prevents work being overwritten
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
11/58
Glossary
Some commonly used terms explained before movingon
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
12/58
Key terms in versioncontrol
Branch a copy of a set of files underversion control which may be developedat different speeds or in different ways
Checkout to copy the latest version of(a file in) the repository to your workingcopy
Commit to copy (a file in) your workingcopy back into the repository as a newversion
Merge to combine multiple changesmade to different working copies of thesame files in the repository
Repository a (shared) database with
the complete revision history of all filesunder version controlGit - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
13/58
Version controlsystems
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
14/58
Click icon to add picture
Click icon to add picture
Click icon to add picture
Very limited and inflexible
Concurrent VersionsSystem (CVS)
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
15/58
Click icon to add picture
Click icon to add picture
Click icon to add picture
Very limited and inflexible
Concurrent VersionsSystem (CVS)
Fills most of the holes found inCVS, but added nothing to itsdevelopment model
Subversion (SVN)
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
16/58
Click icon to add picture
Click icon to add picture
Click icon to add picture
Very limited and inflexible
Click icon to add picture
Concurrent VersionsSystem (CVS)
Fills most of the holes found inCVS, but added nothing to itsdevelopment model
Subversion (SVN)
More feature rich andfunctional
Git
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
17/58
Comparison with SVN
Subversion Git
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
18/58
Comparison with SVN
Subversion
Centralized
Git
Distributed
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
19/58
Comparison with SVN
Subversion
Centralized
Branching can be a pain andis used sparingly
Git
Distributed
Branching is very easy and isa core concept
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
20/58
Comparison with SVN
Subversion
Centralized
Branching can be a pain andis used sparingly
Conflicts frequently occur andrenaming is not handled well
Git
Distributed
Branching is very easy and isa core concept
Conflicts occur less frequent,renaming is properly handled
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
21/58
Comparison with SVN
Subversion
Centralized
Branching can be a pain andis used sparingly
Conflicts frequently occur andrenaming is not handled well
Can be slow due to networklatency
Git
Distributed
Branching is very easy and isa core concept
Conflicts occur less frequent,renaming is properly handled
Very fast since less operationsinvolve network latency
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
22/58
Comparison with SVN
Subversion
Centralized
Branching can be a pain andis used sparingly
Conflicts frequently occur andrenaming is not handled well
Can be slow due to networklatency
Can consume quite some diskspace
Git
Distributed
Branching is very easy and isa core concept
Conflicts occur less frequent,renaming is properly handled
Very fast since less operationsinvolve network latency
Consumes 30 times less diskspace
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
23/58
Distributedversion control
The new generation of version control
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
24/58
Click icon to add picture
A basic, centralized version controlsystem
Users commitchanges to the central repository and a newversion is born to be checked out by other users
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
25/58
Click icon to add picture
A distributed version control system
Each user has a full local copy of the repository. Userscommitchanges and when they want to share it, the push itto the shared repository
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
26/58
Git usage
Basic operations
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
27/58
Tracking a project..
SVN Git
$ svn checkout url $ git clone url
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
28/58
-
8/7/2019 git-12613901533412-phpapp02
29/58
Tracking a project..
SVN Git
$ svn checkout url $ git clone url
My project is tiny - git is overkillWhy would I carry a Swiss knife when Ionly want to open cans?
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
30/58
-
8/7/2019 git-12613901533412-phpapp02
31/58
Tracking a project..
SVN Git
$ svn checkout url $ git clone url
$ svn update $ git pull
$ svn add file $ git add file$ svn rm file $ git rm file
$ svn mv file $ git mv file
$ svn commit $ git commit a
$ svn revert path $ git checkout path
Pretty straightforwarded, huh?
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
32/58
Advanced committing
SVN Git
$ svn mv file $ git mv file
$ svn commit $ git commit a$ svn revert path $ git checkout path
What if you screw up?#re-edit the metadata and update
the tree$ git commit --amend
or
# toss your latest commit away
without changing the working tree$ git reset HEAD^Git - the fast version control
s stem
-
8/7/2019 git-12613901533412-phpapp02
33/58
Solving conflicts
Instant merging
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
34/58
Closer look at pulling..
SVN Git
$ svn checkout url $ git clone url
$ svn update $ git pull
$ svn add file $ git add file
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
35/58
Auto-merging..
SVN Git
$ svn checkout url $ git clone url
$ svn update $ git pull
$ svn add file $ git add file
What actually happens
# Fetch latest changes from origin$ git fetch
# Merge fetched changes intocurrent branch$ git merge refs/heads/master
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
36/58
Auto-merging..
SVN Git
$ svn checkout url $ git clone url
$ svn update $ git pull
$ svn add file $ git add file
What actually happens
Recursive merge strategy create amerged reference tree of commonancestors for three-way merge
fewer merge conflicts can detect and handle renames
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
37/58
Resolving conflicts..
SVN Git
$ svn checkout url $ git clone url
$ svn update $ git pull
$ svn add file $ git add file
Suppose Jeff and Dan both madechanges to the same line in file
CONFLICT (content): Merge conflict in fileAutomatic merge failed; fix conflicts andthen commit the result.
Uh oh. now what?
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
38/58
Resolving conflicts..
SVN Git
$ svn checkout url $ git clone url
$ svn update $ git pull
$ svn add file $ git add file
Well, just merge manually
# run your favourite file mergeapplication$ git mergetool t opendiff
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
39/58
Git - the fast version controls stem
source: http://gitguru.com
-
8/7/2019 git-12613901533412-phpapp02
40/58
Resolving conflicts..
SVN Git
$ svn checkout url $ git clone url
$ svn update $ git pull
$ svn add file $ git add file
and commit!
# commit to resolve the conflict$ git commit
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
41/58
Branching
A core concept
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
42/58
Creating a branch..
SVN Git
$ svn copyurl_of_trunkurl_of_branch
$ svn switchurl_of_branch
$ git branchname_of_branch
$ git checkoutname_of_branch
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
43/58
Creating a branch..
SVN Git
$ svn copyurl_of_trunkurl_of_branch
$ svn switchurl_of_branch
$ git branchname_of_branch
$ git checkoutname_of_branch
Or create and switch to a branchbased on another branch
$ git checkout b new_branchother_branch
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
44/58
Click icon to add picture
Some common scenarios
Git - the fast version controls stem
Why would I require branching?
-
8/7/2019 git-12613901533412-phpapp02
45/58
Scenario 1 Interrupted workflow
Youre finished with part 1 of a new feature butyou cant continue with part 2 before part 1 is
released and tested
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
46/58
Scenario 1 Interrupted workflow
Youre finished with part 1 of a new feature butyou cant continue with part 2 before part 1 is
released and tested
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
47/58
Scenario 2 Quick fixes
While youre busy implementing some featuresuddenly youre being told to drop everything and
fix a newly discovered bug
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
48/58
Scenario 2 Quick fixes
While youre busy implementing some featuresuddenly youre being told to drop everything and
fix a newly discovered bug
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
49/58
Git usageoverview
Just to summarize
Git - the fast version controls stem
Git command sequence
-
8/7/2019 git-12613901533412-phpapp02
50/58
Git command sequence
Source: http://git.or.cz
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
51/58
Tooling
Stuck at Ye Olde Terminal? Not necessarily
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
52/58
Git UI front-ends
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
53/58
Click icon to add picture
Click icon to add picture
Click icon to add picture
OpenInGitGui
Git - the fast version controls stem
Finder extension
-
8/7/2019 git-12613901533412-phpapp02
54/58
Click icon to add picture
Click icon to add picture
Click icon to add picture
OpenInGitGui
Git - the fast version controls stem
Finder extension
TortoiseGit
Git Extensions
Windows Explorerextensions
-
8/7/2019 git-12613901533412-phpapp02
55/58
Click icon to add picture
Click icon to add picture
Click icon to add picture
OpenInGitGui
Git - the fast version controls stem
Finder extension
TortoiseGit
Git Extensions
Windows Explorerextensions
JGit / EGit
Eclipse integration
-
8/7/2019 git-12613901533412-phpapp02
56/58
Conclusion
Why switch to Git?
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
57/58
Reasons to switch to Git
Endless, easy, non-file-system-based,local branches
Enhanced merging strategy
Performance
Advanced features enable betterworkflow
Stashing temporary work
Collaboration before public commits
Git - the fast version controls stem
-
8/7/2019 git-12613901533412-phpapp02
58/58
Closing and Q&A
References
Git: http://git-scm.com/download
Git Docs: http://git-scm.com/documentation
GitX: http://gitx.frim.nl/
TortoiseGit: http://code.google.com/p/tortoisegit/
Git Extensions:http://sourceforge.net/projects/gitextensions/
JGit / EGit: http://www.eclipse.org/egit/
http://git-scm.com/downloadhttp://git-scm.com/documentationhttp://code.google.com/p/tortoisegit/http://sourceforge.net/projects/gitextensions/http://www.eclipse.org/egit/http://www.eclipse.org/egit/http://www.eclipse.org/egit/http://sourceforge.net/projects/gitextensions/http://code.google.com/p/tortoisegit/http://git-scm.com/documentationhttp://git-scm.com/download