Git from SVN

Preview:

Citation preview

Git from SVN

Justin Yoo

Overview

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

Git over SVN

Git SVN

Git over SVN

Git SVN

Commit

Push

Commit

Git over SVN

Git• Commit to my local

repository• Push commits to remote

repository

SVN• Commit to remote

repository

Git over SVN

• Why local repository?– Fast

Git over SVN

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

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

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

Git Basics with SourceTree

• Clone– Copy remote repository to your local

Git Basics with SourceTree

• Branches– Where you’re currently working

Git Basics with SourceTree

• Remotes– Where your commits are pushed

Git Basics with SourceTree

• Working Copy– Where your changes are seen

Git Basics with SourceTree

• Unstaged files– Not yet ready for

commit

• Modified– README.md

• Added– file-a.txt

Git Basics with SourceTree

• Staged files– Ready for commit

Git Basics with SourceTree

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

• Ready for push!

Git Basics with SourceTree

Git Basics with SourceTree

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

Git Basics with SourceTree

• Keep changing and ready for another push

Git Basics with SourceTree

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

already pushed their commits

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

Git Basics with SourceTree

• Time to pull or fetch for sync

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

Git Basics with SourceTree

• Push again and…

Git Basics with SourceTree

• Push success!• Local repository and

remote one are now in sync

Git Best Practices with SourceTree

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

changes

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

Git Best Practices with SourceTree

• Use git-flow approach– SourceTree natively

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

successful-git-branching-model/

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…

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

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

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

Questions?

Recommended