Git tutorial

46
+ Distributed Version Control Nuttapon Pattanavijit

description

 

Transcript of Git tutorial

Page 1: Git tutorial

+Distributed Version Control

Nuttapon Pattanavijit

Page 2: Git tutorial

Reference

• http://git-scm.com

• https://www.atlassian.com/git/tutorial

Page 3: Git tutorial

1. WTF is Version Control ?

Page 4: Git tutorial

Collaboration

Page 5: Git tutorial

If someone blow up your code!

what will you do if you use something like dropbox?

Page 6: Git tutorial

Snapshot sounds good

Page 7: Git tutorial

Snapshot sounds good?

Page 8: Git tutorial

Local Version Control

Page 9: Git tutorial

Centralized Version Control Systems

Page 10: Git tutorial

Distributed Version Control Systemgit is DVCS

Page 11: Git tutorial

2. Git?

Page 12: Git tutorial

History of Git

• Developed for Linux Kernel project.

• Speed, Simple design

• Non-linear development

• Fully distributed

• Able to handle large projects

Page 13: Git tutorial

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.

Page 14: Git tutorial

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.

Page 15: Git tutorial

3. Git Basic

Page 16: Git tutorial
Page 17: Git tutorial

Git Basic

git init initializes new repository

git clone create a copy

Page 18: Git tutorial

Git Basic

Page 19: Git tutorial

Git Basic

git add add files to staging

git commit snapshot project

Page 20: Git tutorial
Page 21: Git tutorial
Page 22: Git tutorial
Page 23: Git tutorial

4. Undoing changes

Page 24: Git tutorial

Undoing Changesgit checkout previous version

git revert undo committed snapshot

git reset undo changes in working directory

Page 25: Git tutorial

5. Branching

Page 26: Git tutorial
Page 27: Git tutorial

git branch testing

Page 28: Git tutorial
Page 29: Git tutorial

git checkout testing

Page 30: Git tutorial

git commit -a -m “made a change”

Page 31: Git tutorial

git checkout master

Page 32: Git tutorial

git commit -a -m “made other changes”

Page 33: Git tutorial

6. Merging

Page 34: Git tutorial
Page 35: Git tutorial

git checkout mastergit merge iss53

Page 36: Git tutorial

git checkout mastergit merge iss53

Page 37: Git tutorial

If two branches edit same file?

How to handle merge conflict?

Page 38: Git tutorial

7. Remote Repositories

Page 39: Git tutorial

Demo

Page 40: Git tutorial

Remote Repositories

git pull fetch + merge into current branch

git push update local repo to remote repo

Page 41: Git tutorial
Page 42: Git tutorial

8. Feature Branch Workflow

Page 43: Git tutorial

git checkout -b my_feature master

=git checkout master

git branch my_feature

Page 44: Git tutorial

git push -u origin master

Page 45: Git tutorial

git pull

Page 46: Git tutorial

git push -u origin my_featuregit checkout master

git pullgit merge my_feature

git push