+Distributed Version Control
Nuttapon Pattanavijit
Reference
• http://git-scm.com
• https://www.atlassian.com/git/tutorial
1. WTF is Version Control ?
Collaboration
If someone blow up your code!
what will you do if you use something like dropbox?
Snapshot sounds good
Snapshot sounds good?
Local Version Control
Centralized Version Control Systems
Distributed Version Control Systemgit is DVCS
2. Git?
History of Git
• Developed for Linux Kernel project.
• Speed, Simple design
• Non-linear development
• Fully distributed
• Able to handle large projects
Snapshot of project over time
basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. To be efficient, if files have not changed, Git doesn’t store the file again—just a link to the previous identical file it has already stored.
Git workflow
1. You modify files in your working directory.
2. You stage the files, adding snapshots of them to your staging area.
3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
3. Git Basic
Git Basic
git init initializes new repository
git clone create a copy
Git Basic
Git Basic
git add add files to staging
git commit snapshot project
4. Undoing changes
Undoing Changesgit checkout previous version
git revert undo committed snapshot
git reset undo changes in working directory
5. Branching
git branch testing
git checkout testing
git commit -a -m “made a change”
git checkout master
git commit -a -m “made other changes”
6. Merging
git checkout mastergit merge iss53
git checkout mastergit merge iss53
If two branches edit same file?
How to handle merge conflict?
7. Remote Repositories
Demo
Remote Repositories
git pull fetch + merge into current branch
git push update local repo to remote repo
8. Feature Branch Workflow
git checkout -b my_feature master
=git checkout master
git branch my_feature
git push -u origin master
git pull
git push -u origin my_featuregit checkout master
git pullgit merge my_feature
git push