Published on

A presentation on GIT - a distributed version control system made for Software Engineering Course.

Published in: 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


  2. 2. Trivia  Git was initially designed and developed by Linus Torvalds for Linux kernel development.  Adopted by many other projects.  Git is free software distributed under the terms of the GNU General Public License.
  3. 3. Version Control System  Version control, also known as source control or revision control is an integral part of any development workflow. Why? It is essentially a communication tool, just like email or IM, but it works with code rather than human conversation.  allows programmers to easily communicate their work to other programmers  allows a team to share code  maintains separate “production” versions of code that are always deployable  allows simultaneous development of different features on the same codebase  keeps track of all old versions of files  prevents work being overwritten
  4. 4. A basic version control system
  5. 5. A Distributed Version Control system
  6. 6. What is GIT ?  A Distributed revision control / source-code management system.  Emphasis : SPEED  Helps to make snapshots of the project state every time.  Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.
  7. 7. Why GIT ?  Distributed & Decentralized  Client = Server  No network connectivity required.  Very Fast over others
  8. 8. Distributed development GIT Characteristics  Strong support for non-linear development  Distributed development  Compatibility with existing systems/protocols  Efficient handling of large projects  Cryptographic authentication of history  Toolkit-based design  Pluggable merge strategies  Garbage accumulates unless collected  Periodic explicit object packing
  9. 9. Workflow in a centralized rcs  The Developer syncs a local copy of the latest version files in the central server.  Opens them for editing.  Regularly syncs with the central server for updates made by other developers.  Submits the changes back to the server after validation.  Meanwhile if the developer wants to go back to an older version contact the central server to cache a local copy.
  10. 10. Regular Workflow in GIT  The Developer syncs not only the latest version of the files but the entire git history along with it.  Project Size ? Not very large as expected  .git directory internally stores the details of every commit operation.  The developer opens the file for modifications  Regularly Syncs with a remote server for updates from other developers.  Finally pushes his files to the remote server after validation.  Meanwhile if the developer wants to go back to an older version he need not contact the central server to cache a local copy. He can do it locally !
  11. 11. Regular Workflow in GIT  Creating a repository. $ cd project-dir $ git init  To clone an existing repository. $ git clone git://  The project data is stored in the .git directory.  Git clone copies the entire repository for local modifications.
  12. 12. Regular Workflow in GIT  Add files to the staging area: $ git add filenamelist $ git add file1 file2 file3 …..  Modify files and re-add them. Why? : Else, changes will be local to your system even after a commit.  Check project status through $ git status –s
  13. 13. Regular Workflow in GIT  Difference in modified files: $ git diff $ git diff cached <for staged changes>  Record your details before commit $ git config --global Your Name $ git config --global  Commit the staged changes $ git commit –m “message description of the changes”
  14. 14. Regular Workflow in GIT  To remove a file from GIT tracking $ git rm filename <To also remove it from local disk> $ git rm –cached <To keep it still in the directory>  To view the entire log of commits $ git log $ git log --online
  15. 15. Regular Workflow in GIT
  16. 16. Regular Workflow in GIT
  17. 17. Branching in GIT
  18. 18. GIT vs others  Other systems tend to store data as changes to a base version of each file.
  19. 19. GIT vs others  Git stores data as snapshots of the project over time.
  20. 20. Branching in GIT  Branching : many concurrent versions of the project  Default Branch : Master  To create a branch $ git branch (branchname)  To navigate to the created branch $ git checkout (branchname)  To bring / merge the changes into the current branch $ git merge (branchname)  GIT automatically reports Merge Conflicts, else merges the last committed version of the merged branch.
  21. 21. Sharing and updating projects  Git doesnt have a central server like Subversion.  All of the commands so far have been done locally, just updating a local database.  Once you have a Git repository, either one that you set up on your own server, or one hosted someplace like GitHub, you can tell Git to either push any data that you have that is not in the remote repository up, or you can ask Git to fetch differences down from other repo.
  22. 22. Sharing and updating projects  To add a remote repository: $ git remote add [alias] git://  To download new branches and data from a remote repository $ git fetch [alias]  To fetch from a remote repo and try to merge into the current branch $ git pull [alias]  To write your changes back to a server $ git push [alias] [branch]
  23. 23. Undo and revert back  $ git log filename  We can modify and re commit an old version $ git checkout <commit version> filename  Or go back to the latest version $ git checkout HEAD filename  To see who changed the file last. $ git blame filename
  24. 24. Some good practices with GIT  Commit often  Pull often  Use checkout and reset with caution  Create your own repository anywhere
  25. 25. GIT Internals  Git stores a commit object that contains a pointer to the snapshot of the content staged. GIT Internals
  26. 26. GIT Internals  If some changes are made and committed again, the next commit stores a pointer to the commit that came immediately before it.
  27. 27. GIT Internals  Master branch points to the last commit made. Every time one commits, it moves forward automatically. Creating a new branch creates a new pointer.
  28. 28. GIT Internals  Git keeps a special pointer called HEAD, a pointer to the local branch one is currently on.
  29. 29. GIT Internals
  30. 30. GIT Internals  Switching back and forth between branches, merging them together is possible.
  31. 31. Portability and alternatives  Git is primarily developed on GNU/Linux, although it also supports major operating systems including BSD, Solaris, OS X, and Windows.  The JGit implementation of Git is a pure Java software library, and in use as a Git client for the Eclipse IDE.  The Dulwich implementation of Git is a pure Python software component for Python 2.  The libgit2 implementation of Git is an ANSI C software library. It is used as the basis for Git libraries for the Ruby and Python programming languages.  The Plastic SCM versioning system contains its own implementation of the Git protocol, to allow Plastic SCM clients to interoperate with remote Git repositories.
  32. 32. Source Code Hosting  Using GIT Repositories:
  33. 33. github  A web-based hosting service for software development projects that use the Git rcs.  GitHub offers both paid plans for private repositories, and free accounts for open source projects.  The site provides social networking functionality such as feeds, followers and the network graph to display how developers work on their versions of a repository.
  34. 34. GIT in use…
  35. 35. Reference  Pro Git book - Scott Chacon    Git Tutorials across the web.  Demo …