Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,981
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
54
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. GIT BySerhiy Yakovyn
  • 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. GIT to SVN mappingCreate the new repo:svnadmin create reposvn import file://repogit initgit add .git commit
  • 4. GIT to SVN mappingTo revert:svn revert pathGit checkout path
  • 5. GIT to SVN mappingTo commit:svn commitgit commit -a
  • 6. GIT to SVN mappingBranching:svn copy http://example.com/svn/trunkhttp://example.com/svn/branches/branchsvn switch http://example.com/svn/branches/branchgit branch branchgit checkout branch
  • 7. GIT to SVN mappingList:svn list http://example.com/svn/branches/git branch
  • 8. GIT to SVN mappingMoving between revisions:svn update -r revsvn updategit checkout revgit checkout prevbranch
  • 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:HEADhttp://example.com/svn/branches/branchgit merge branch
  • 10. GIT to SVN mappingPick commit from another branch:svn merge -c rev urlgit cherry-pick rev
  • 11. GIT to SVN mappingCloning remote repo:svn checkout urlgit clone url
  • 12. GIT to SVN mappingRemote branch:svn switch urlgit checkout --track -b branch origin/branch
  • 13. GIT to SVN mappingRemote update:svn updategit pull
  • 14. GIT to SVN mappingRemote commit:svn commitgit push
  • 15. Some commonly used workflows1. Write new features in feature branches.2. Integrate on the master branch.3. Deploy from the release branch.
  • 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. 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. 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. 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. Some commonly used workflows1. Pull to update your local mastergit checkout mastergit pull origin master
  • 21. Some commonly used workflows2. Check out a branchgit checkout -b <branch>
  • 22. Some commonly used workflows3. Do work in your feature branch, committingearly and oftenHacking…git commitHacking…git commitHacking…git commit
  • 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. Some commonly used workflows5. Interactive rebase (squash) your commitsgit rebase -i origin/master
  • 25. Some commonly used workflows6. Merge your changes with mastergit checkout mastergit pullgit merge <branch>
  • 26. Some commonly used workflows7. Push your changes to the upstreamgit push origin master
  • 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. GIT SVN2. Hacking. Just usual GITgit checkout –b <branch>hacking…git commithacking…
  • 29. GIT SVN3. Updating from SVNgit svn rebaseorgit svn fetchgit svn rebase –l
  • 30. GIT SVN4. Preparing your workgit rebase –i remote/<branch>
  • 31. GIT SVN5. Committing back to SVNgit svn dcommit
  • 32. GIT SVN6. Branching:git svn branch
  • 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. 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. GIT internalsgit cat-file - provides content or type and sizeinformation for repository objectsBLOB – basic object type. Every file is stored in it
  • 36. GIT internalsTree object
  • 37. GIT internalsTree objectgit update-indexgit write-treegit read-tree
  • 38. GIT internalsCommit Objectsgit commit-tree
  • 39. GIT internalsGit Referencesgit update-ref
  • 40. Questions?
  • 41. Useful linkshttp://progit.org/book/Git Workflow – GitHubGit SVN Workflowhttp://maymay.net/blog/2009/02/24/how-to-use-git-svn-as-the-only-subversion-client-youll-need/and many-many-many others…