Session git


Published on

Understanding, Using the Git source control system with some case studies.

Published in: Education, Technology
1 Like
  • Be the first to comment

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

No notes for slide

Session git

  1. 1. Lets talk about GIT Stupid, fast, distributed content tracker Roni Saha Sr. Software EngineerRightbrain Solution Limited & Emicrograph Business Solution
  2. 2. Git uses a distributed model Centralized Model Distributed Model(CVS, Subversion, Perforce) (Git, Mercurial) Result: Many operations are local
  3. 3. Git local file lifecycleuntracked unmodified modified staged edit the file add the file stage the file remove the file commit
  4. 4. Overview of Git Workflow/Commands
  5. 5. Git commands command descriptiongit clone url [dir] copy a git repository so you can add to itgit add files adds file contents to the staging areagit commit records a snapshot of the staging areagit status view the status of your files in the working directory and staging areagit diff shows diff of what is staged and what is modified but un-stagedgit pull fetch from a remote repo and try to merge into the current branchgit push push your new branches and data to a remote repository others: init, reset, branch, checkout, merge, log, tag
  6. 6. Typical Development Workflow Get the code git clone some-repo git pull Modify Code Cerate Delete/Edit Save the changes git add git commit -m "message" Sync with remote git pull git push
  7. 7. Branch VS TagBranch Tags• A branch is just a line of • Milestone in the life of development project• “Branch head” mean a • Read Only, i.e. reference reference to the most to a fixed commit id recent commit on a branch
  8. 8. Merge, The Blessing!!Some merge StrategiesResolve This can only resolve two headsRecursive Default strategy when pulling or merging one branchOctopus More than two branchesOurs/Theirs Just mark as mergedNo-commit Do not create a new commit automatically
  9. 9. Conflict, The Devil!!
  10. 10. Resolve Conflict Resolve• Decide not to actions! merge • $ git merge --abort• Resolve the • Edit the files into conflicts shape then commit Conflict
  11. 11. Client is always right!!Git allows you to use git locally and use SVN as a remote repository Create Git clone of Subversion repo • $ git svn clone -s svn:// Update from SVN • $ git svn rebase Commit to SVN • $ git svn dcommit
  12. 12. Case Studies
  13. 13. Merge Commands Merge branches fixes and enhancement to the current branch, making an octopus merge: $ git merge fixes enhancements Merge branch obsolete into the current branch, using ours merge strategy: $ git merge -s ours obsolete Merge branch partial into the current branch, but do not make a new commit automatically: $ git merge --no-commit partial Cancel a merge: $ git merge --abort
  14. 14. Cancel/Fix a commit From latest to some point $ git reset –<hard/soft> <where> ….. Edit ……. $ git add .... $ git commit -c ORIG_HEAD Some commit in the past $ git revert <commit> Fix latest commit $ git commit --amend
  15. 15. Partial commit You made several unrelated changes to the same file $ git add -p <Opens up an interactive session> <Choose which hunk of each patch to add to the index>
  16. 16. Pulling into a dirty tree • git stash save, git pull, git stash pop
  17. 17. Suspend work for a fix• git stash save, do the fix, commit, git stash pop
  18. 18. Moving work to a branch
  19. 19. Moving work to a branch Switch to (Create) the “v1.12" branch • git checkout v1.12[git merge master] • Or git checkout -b v1.12 Forcibly move master back to early stage • git branch -f master HEAD^^^
  20. 20. Any More… Case Studies/Question?
  21. 21. Thank You