Published on

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. GIT BySerhiy Yakovyn
  2. 2. Agenda• Describe how GIT commands corresponds to SubVersioN ones.• Provide some commonly used workflows.• Explain how to use GIT when your team works with SVN.• Give a quick overview of GIT internals
  3. 3. GIT to SVN mappingCreate the new repo:svnadmin create reposvn import file://repogit initgit add .git commit
  4. 4. GIT to SVN mappingTo revert:svn revert pathGit checkout path
  5. 5. GIT to SVN mappingTo commit:svn commitgit commit -a
  6. 6. GIT to SVN mappingBranching:svn copy switch branch branchgit checkout branch
  7. 7. GIT to SVN mappingList:svn list branch
  8. 8. GIT to SVN mappingMoving between revisions:svn update -r revsvn updategit checkout revgit checkout prevbranch
  9. 9. GIT to SVN mapping(assuming the branch was created in revision 20and you are inside a working copy of trunk)svn merge -r 20:HEAD merge branch
  10. 10. GIT to SVN mappingPick commit from another branch:svn merge -c rev urlgit cherry-pick rev
  11. 11. GIT to SVN mappingCloning remote repo:svn checkout urlgit clone url
  12. 12. GIT to SVN mappingRemote branch:svn switch urlgit checkout --track -b branch origin/branch
  13. 13. GIT to SVN mappingRemote update:svn updategit pull
  14. 14. GIT to SVN mappingRemote commit:svn commitgit push
  15. 15. Some commonly used workflows1. Write new features in feature branches.2. Integrate on the master branch.3. Deploy from the release branch.
  16. 16. Some commonly used workflows1. Write new features in feature branches.# create a new feature branch in the remote repo named feature_branchgit push origin master:refs/heads/feature_branch# make sure weve got everything updated from the remote repogit fetch origin# create a local branch named feature_branch that tracks# the remote feature_branchgit branch --track feature_branch origin/feature_branch# check out the new branchgit checkout feature_branch
  17. 17. Some commonly used workflows2. Integrate on master branch.git merge mastergit checkout mastergit merge feature_branch# this has to be in competition for one of the least intuitive# commands ever, but it removes the remote branchgit push origin :refs/heads/feature_branch# remove the local branchgit branch -d feature_branch
  18. 18. Some commonly used workflows3. Deploy from the release branch.# checkout the deploy branchgit checkout deploy# pull the deploy branch, just to be sure everythings up to dategit pull origin deploy# merge the master branch into the deploy branchgit merge master# tag the release that were about to makegit tag -a -m "My comments about this release" [tag_name]# push it all up to the remote repositorygit push --tags origin deploy# switch back to the master branch,# since we never do any work on the deploy branchgit checkout master
  19. 19. Some commonly used workflows1. Pull to update your local master2. Check out a feature branch3. Do work in your feature branch, committing earlyand often4. Rebase frequently to incorporate upstreamchanges5. Interactive rebase (squash) your commits6. Merge your changes with master7. Push your changes to the upstream
  20. 20. Some commonly used workflows1. Pull to update your local mastergit checkout mastergit pull origin master
  21. 21. Some commonly used workflows2. Check out a branchgit checkout -b <branch>
  22. 22. Some commonly used workflows3. Do work in your feature branch, committingearly and oftenHacking…git commitHacking…git commitHacking…git commit
  23. 23. Some commonly used workflows4. Rebase frequently to incorporate upstreamchangesgit fetch origin mastergit rebase origin/masterOr (longer way):git checkout mastergit pullgit checkout <branch>git rebase master
  24. 24. Some commonly used workflows5. Interactive rebase (squash) your commitsgit rebase -i origin/master
  25. 25. Some commonly used workflows6. Merge your changes with mastergit checkout mastergit pullgit merge <branch>
  26. 26. Some commonly used workflows7. Push your changes to the upstreamgit push origin master
  27. 27. GIT SVNHow to use GIT when your team works withSVN?1. Creating working copy? – no! working repo.git svn init …Some magic git svn fetchOr (if you are lucky! – I’ve never been):git svn clone …
  28. 28. GIT SVN2. Hacking. Just usual GITgit checkout –b <branch>hacking…git commithacking…
  29. 29. GIT SVN3. Updating from SVNgit svn rebaseorgit svn fetchgit svn rebase –l
  30. 30. GIT SVN4. Preparing your workgit rebase –i remote/<branch>
  31. 31. GIT SVN5. Committing back to SVNgit svn dcommit
  32. 32. GIT SVN6. Branching:git svn branch
  33. 33. GIT internals.git contentHEAD – the checked out branchconfig – configuration optionsdescription – description (used by GitWeb)hooks/index - staginginfo/objects/ - contentrefs/ - pointers to commit objects in branches
  34. 34. GIT internalsGit is a content-addressable filesystem.This means that at the core of Git is a simplekey-value data store.You can insert any kind of content into it, and itwill give you back a key that you can use toretrieve the content again at any time.git hash-object – stores the file in GIT
  35. 35. GIT internalsgit cat-file - provides content or type and sizeinformation for repository objectsBLOB – basic object type. Every file is stored in it
  36. 36. GIT internalsTree object
  37. 37. GIT internalsTree objectgit update-indexgit write-treegit read-tree
  38. 38. GIT internalsCommit Objectsgit commit-tree
  39. 39. GIT internalsGit Referencesgit update-ref
  40. 40. Questions?
  41. 41. Useful links Workflow – GitHubGit SVN Workflow many-many-many others…