git from svn

32
Git from SVN Justin Yoo

Upload: justin-yoo

Post on 08-Aug-2015

260 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Git from SVN

Git from SVN

Justin Yoo

Page 2: Git from SVN

Overview

• Git over SVN• Git Basics with SourceTree• Git Best Practices with SourceTree

Page 3: Git from SVN

Git over SVN

Git SVN

Page 4: Git from SVN

Git over SVN

Git SVN

Commit

Push

Commit

Page 5: Git from SVN

Git over SVN

Git• Commit to my local

repository• Push commits to remote

repository

SVN• Commit to remote

repository

Page 6: Git from SVN

Git over SVN

• Why local repository?– Fast

Page 7: Git from SVN

Git over SVN

• Why local repository?– Fast– Can create branches as many as I want• Branches only I want can be pushed to remote

Page 8: Git from SVN

Git over SVN

• Why local repository?– Fast– Can create branches as many as I want• Branches only I want can be pushed to remote

– Don’t have to worry about commits from others

Page 9: Git from SVN

Git over SVN

• Why local repository?– Fast– Can create branches as many as I want• Branches only I want can be pushed to remote

– Don’t have to worry about commits from others– Can commit even if remote is not connectable

Page 10: Git from SVN

Git Basics with SourceTree

• Clone– Copy remote repository to your local

Page 11: Git from SVN

Git Basics with SourceTree

• Branches– Where you’re currently working

Page 12: Git from SVN

Git Basics with SourceTree

• Remotes– Where your commits are pushed

Page 13: Git from SVN

Git Basics with SourceTree

• Working Copy– Where your changes are seen

Page 14: Git from SVN

Git Basics with SourceTree

• Unstaged files– Not yet ready for

commit

• Modified– README.md

• Added– file-a.txt

Page 15: Git from SVN

Git Basics with SourceTree

• Staged files– Ready for commit

Page 16: Git from SVN

Git Basics with SourceTree

• Local master is 2 commits ahead from remote’s origin/master

• Ready for push!

Page 17: Git from SVN

Git Basics with SourceTree

Page 18: Git from SVN

Git Basics with SourceTree

• Local master and remote’s origin/master are in sync now

Page 19: Git from SVN

Git Basics with SourceTree

• Keep changing and ready for another push

Page 20: Git from SVN

Git Basics with SourceTree

• What???!!! • Push fails!!!• Because:– Other developers have

already pushed their commits

– Therefore your remote snapshot is not up-to-date

Page 21: Git from SVN

Git Basics with SourceTree

• Time to pull or fetch for sync

Page 22: Git from SVN

Git Basics with SourceTree

Pull• Downloads all changes from

remote• Changes are merged to local

repository– fetch + merge

• Recommended for most cases

Fetch• Downloads all changes from

remote• Changes are NOT merged to

local repository

• Recommended when:– pull fails– don’t want auto merge

Page 23: Git from SVN

Git Basics with SourceTree

• Push again and…

Page 24: Git from SVN

Git Basics with SourceTree

• Push success!• Local repository and

remote one are now in sync

Page 25: Git from SVN

Git Best Practices with SourceTree

• Always sync first before merge and push– Other developers have already pushed their

changes

Page 26: Git from SVN

Git Best Practices with SourceTree

• Commit to your local as often and small as possible– DO NOT commit a big chunk of changes– Commit small changes at one time• Other developers can easily trace it

Page 27: Git from SVN

Git Best Practices with SourceTree

• Use git-flow approach– SourceTree natively

supports it– http://nvie.com/posts/a-

successful-git-branching-model/

Page 28: Git from SVN

Git Best Practices with SourceTree

• Git-Flow?– Best practice for git

branching model– Always work on your

local branch with prefix of:• hotfix-• feature-• Etc…

Page 29: Git from SVN

Git Best Practices with SourceTree

• Git-Flow?– Then merge those

branches to dev and push

– Once everything is fine, dev can be merged to master

– Production release is performed from master

Page 30: Git from SVN

Git Best Practices with SourceTree

• Use fork– Cloning the original

remote repo to another remote repo

– Work on your own forked repo

– Send pull request to original repo

Page 31: Git from SVN

Git Best Practices with SourceTree

• Why fork?– Sending pull request is a great starting point of

code review– Can identify if the changes can be merged without

concern– Depending on code maintainer’s willingness• Don’t have to use fork, unless the main code

maintainer is willing to use

Page 32: Git from SVN

Questions?