A Git introduction for SVN users. Including bidirectional bridge Git-Svn.
Git vs SVN@denkeni
View Slide
Git - first impressions• Distributed Version Control System • Created by Linus Torvalds for Linux kernel projectmanagement. • Fast, lightweight. • GitHub • "Local branching on the cheap"
But git is more complex and requires more managementthan svn, definitely.
Git SVNgit clone svn checkoutgit checkout xxx.m svn revert xxx.mgit checkout $branch_name svn switch $branch_urlgit checkout $commitsvn merge -r301:300 xxx.m svn commitgit reset --hard HEAD svn revert -R .git pull (= git fetch + git merge)svn updategit revert $commit -
Remote-dependent(SVN) vs Local-Remote(Git)
Uncommitted (Local)Committed (Remote)svn commit
Uncommitted (Local)Committed (Remote)svn commitWorking space/directoryIndex / Staging areaLocal repositoryRemote repositorygit add xxx.mgit commitgit push
A typical case of SVNOne trunk development
svn update (solve conflicts)svn committrunkRemoteLocal
RemoteLocaltrunk
A typical case of gitBranch merging development
masterRemoteLocalmastergit branch $branch_namegit checkout $branch_name
RemoteLocalmasterbranch git commitmaster
RemoteLocalmastergit checkout masterbranchmaster
RemoteLocalmastergit merge $branch_namegit pushbranchmaster (other people pushed something)
RemoteLocal masterbranchmaster
(Git-SVN: Use Git client for SVN remote repository)My Git-SVN Flow
trunkmasterRemoteLocal
RemoteLocalmastertrunkbranch
RemoteLocalmastertrunkgit svn rebase(≈git pull)(≈svn update)branch
RemoteLocaltrunkbranchmaster
RemoteLocaltrunkmastergit rebase master(solve conflicts)branch
RemoteLocaltrunkmasterbranch
RemoteLocaltrunkmastergit rebase master -i(solve conflicts)(squash commits into one)branch
RemoteLocaltrunkmasterbranchgit merge branch
RemoteLocaltrunkmastergit svn dcommit(≈git push)branch
"A successful Git branching model."Git Flow
Learning Resources• 《Pro Git》by Scott Chacon(範例多易學,有中文版)http://git-scm.com/book/ • Try Git: Code School(線上學 Git 指令)https://try.github.io/ • ihower 的《Git版本控制系統》http://ihower.tw/git/ • Will 保哥的《30 天精通 Git 版本控管》(深入淺出)https://github.com/doggy8088/Learn-Git-in-30-days • GitSvnComparisonhttps://git.wiki.kernel.org/index.php/GitSvnComparsion • Tech Talk: Linus Torvalds on githttp://youtu.be/4XpnKHJAok8