Git introduction


Published on

Gives an abstract idea about what a version control system(git) is?

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
  • git
  • Git o
  • Git introduction

    1. 3. <ul><ul><li>What is versioncontrol </li></ul></ul><ul><ul><li>What is Git </li></ul></ul><ul><ul><li>Installing Git </li></ul></ul><ul><ul><li>A Short History of Git </li></ul></ul><ul><ul><li>How git is different </li></ul></ul><ul><ul><li>Understanding Difference </li></ul></ul><ul><ul><li>A Basic Workflow </li></ul></ul><ul><ul><li>Git Commands </li></ul></ul><ul><ul><li>Bibliography </li></ul></ul>
    2. 4. <ul><li>  Version control system is a system that records changes to a file or set of files over time. </li></ul><ul><li>Version Control System (VCS) allows you to revert individual files or entire project back to a previous state. </li></ul><ul><li>Allows you to compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more useful things than just a time stamped directory. </li></ul>
    3. 5. <ul><li>Git  is an open source distributed version control system with an emphasis on speed and efficiancy. </li></ul><ul><li>Git was initially designed and developed by LinusTorvalds  for Linux Kernal Developement. </li></ul><ul><li>“ I”m an egotistical bastard, and I name all my projects after myself. First Linux, now git.” – Linus </li></ul>
    4. 6. <ul><li>Daily snapshots of the main Git development branch are available at </li></ul><ul><li> </li></ul><ul><li>UBUNTU- apt-get git-core </li></ul><ul><li>WINDOWS- </li></ul><ul><li>Get the installer and follow onscreen instructions. </li></ul>
    5. 7. <ul><li>During Linux kernel maintenance (1991–2002), software changes were passed around as patches and archived files. In 2002, BitKeeper a proprietary SCM project started. </li></ul><ul><li>In2005 company that developed BitKeeper broke down,so the tool was nolonger offered free of cost. </li></ul><ul><li>In April 2005 Linus Torvalds,wrote his own source code management system that became what is now called as Git. </li></ul>Linux Logo
    6. 8. <ul><li>Everything is local,and fully distributed.means </li></ul><ul><li>Not just check out latest snapshot of the files but fully mirror the repository. </li></ul><ul><li>So  if the server dies, or the harddisk of central database becomes corrupted any of the client repositories can be copied back up to the server to restore it. </li></ul><ul><li>Every checkout is really a full backup of all the data. </li></ul><ul><li>In SVN and CVS, you can edit files, but you can’t commit changes to your database,when you are not connected to the server </li></ul>
    7. 9. <ul><li>Performing a diff </li></ul><ul><li>Viewing file history </li></ul><ul><li>Committing changes </li></ul><ul><li>Merging branches </li></ul><ul><li>Obtaining any other revision of a file </li></ul><ul><li>Switching branches </li></ul><ul><li>No Network Needed for the above operations. </li></ul>
    8. 10. <ul><li>Git Stores Data as snapshots of project over time. </li></ul><ul><li>  basically git takes a picture of how all your files look like at that moment and stores a reference to that snapshot. </li></ul><ul><li>Others store data as changes to a base version of each file. </li></ul>
    9. 11. <ul><li>Edit files </li></ul><ul><li>Stage the changes </li></ul><ul><li>Review your changes </li></ul><ul><li>Commit the changes </li></ul><ul><li>Vim/Eclipse/QtCreator </li></ul><ul><li>git add (file) </li></ul><ul><li>git status </li></ul><ul><li>git commit </li></ul>
    10. 12. <ul><li>You modify files in your working directory. </li></ul><ul><li>You stage the files, adding snapshots of them to your staging area. </li></ul><ul><li>You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory. </li></ul><ul><li>you can easily push changes to a remote server when you get to a network connection. </li></ul>
    11. 13. <ul><li>git config </li></ul><ul><li>git config --global “satyendra.Jaladi” </li></ul><ul><li>git config --global [email_address] </li></ul><ul><li>This is stored in ~/.gitconfig file or etc/gitconfig or .git/config </li></ul><ul><li>To view the configuration </li></ul><ul><li>cat ~/.gitconfig </li></ul>
    12. 14. <ul><li>git init </li></ul><ul><li>Initializing a Repository in ExistingDirectory. </li></ul><ul><li>creates a .git(hidden)directory in your current working directory that is currently empty. </li></ul><ul><li>A working tree(repository) has a .git directory at the top level. </li></ul>
    13. 15. <ul><li>.git directory contents:- </li></ul><ul><li>config -- configuration file, just like a .ini file. </li></ul><ul><li>objects/* -- The object repository. </li></ul><ul><li>refs/heads/* --,userdefnd </li></ul><ul><li>refs/tags/* -- tags [41 char strings] </li></ul><ul><li>logs/* -- logs </li></ul><ul><li>refs/remotes/* -- tracking others work </li></ul><ul><li>Index – the index “cache” (speeds things up) </li></ul>
    14. 16. <ul><li>Index is a directory of blob represents the next commit,index does the staging. </li></ul><ul><li>“ add files ” to put them in the index,including current content(i.e files are staged for commit) </li></ul><ul><li>“ Commit” – takes the current index and makes it a real commit object. </li></ul><ul><li>HEAD – points to the current branch.(where commits occur.contains a pointer to refs/heads/*) </li></ul>
    15. 17. <ul><li>Cloning an Existing Repository </li></ul><ul><li>git clone </li></ul><ul><li>git clone git:// </li></ul><ul><li>Files are pulled into qt-mobility directory. </li></ul><ul><li>git clone git:// mymobility . Files are pulled into mymobility directory. </li></ul>
    16. 18. <ul><li>git add </li></ul><ul><li>echo &quot;TODO: Create documentation&quot; > README.txt </li></ul><ul><li>notepad README.txt add some text and save it. </li></ul><ul><li>touch README.txt </li></ul><ul><li>git add README.txt </li></ul><ul><li>git add Filename works for individual files. </li></ul><ul><li>git add . </li></ul><ul><li>This will add all of your current files into your new repository --index (i.e files are staged for commit.) </li></ul>
    17. 19. <ul><li>git commit </li></ul><ul><li>After making changes to README.txt the file is staged and ready for commit.this is observed with git status or git diff. </li></ul><ul><li>Git commit will launch the editor $EDITOR env variable.or choice editor is set with </li></ul><ul><li>git config --global core.editor   </li></ul><ul><li>Skip Approach. git commit –a -m &quot;Story 01: Fix failing case” </li></ul><ul><li>skip the staging area.(i.e git add is skipped.)  easy </li></ul>
    18. 20. <ul><li>git log </li></ul><ul><li>After cloning a repo git clone git:// </li></ul><ul><li>Want to know what has happened in this repo. </li></ul><ul><li>git log command does the job in command prompt. </li></ul><ul><li>Gitk is a gui version of the git log command. </li></ul><ul><li>This lets you know every detail in the repo. </li></ul><ul><li>gitk& --- launches the git visualizer. </li></ul>
    19. 21. <ul><li>  git branch </li></ul><ul><li>A branch in Git is simply a lightweight movable pointer to the snapshot. </li></ul><ul><li>Git branch operation is very lightweight. </li></ul><ul><li>$ git add README INSTALL LICENSE </li></ul><ul><li>$ git commit -a -m “initial commit of my project” </li></ul><ul><li>  create a new branch </li></ul><ul><li>git branch experiment </li></ul>
    20. 23. <ul><li>$ git branch </li></ul><ul><li>* default </li></ul><ul><li>experiment </li></ul><ul><li>Check the HEAD is on default. </li></ul><ul><li>git checkout experiment </li></ul><ul><li>Now Check the HEAD is on experiment </li></ul><ul><li>git checkout default </li></ul><ul><li>* default </li></ul><ul><li>experiment </li></ul>experiment
    21. 24. <ul><li>git merge </li></ul><ul><li>git checkout default </li></ul><ul><li>git merge experiment </li></ul><ul><li>Now experiment branch is merged into default. </li></ul><ul><li>And the HEAD is at default. </li></ul>
    22. 25. <ul><li>git protocols </li></ul><ul><li>file:// Protocol--( Local protocol) git clone file:///opt/git/project.git </li></ul><ul><li>http/s Protocol --(slow)  The fetch process is a series of GET requests. </li></ul><ul><li>  ssh:// Protocol—(efficient) git clone user@server:project.git (or) </li></ul><ul><li>git push origin master (efficaint transport protocol) </li></ul><ul><li>  git:// Protocol (Fast) $ git clone </li></ul><ul><li>git is a special daemon that comes packaged with Git. it listens on a dedicated port (9418). </li></ul><ul><li>git Protocol is similar to the SSH protocol but without encryption and authentication overhead. </li></ul>
    23. 26. <ul><li>Generate SSH Public Key </li></ul><ul><li>$ cd ~/.ssh </li></ul><ul><li>$ ls </li></ul><ul><li>authorized_keys2 id_dsa known_hosts </li></ul><ul><li>config </li></ul><ul><li>ssh-keygen -t rsa Password is not needed so press Return for all prompts. </li></ul><ul><li>cat ~/.ssh/ </li></ul><ul><li>This is the public key that you are required to copy and paste into your account on github/gitorious. </li></ul>
    24. 27. <ul><li>git pull </li></ul><ul><li>  git pull fetches from origin by default and merges into the current branch. </li></ul><ul><li>$ git pull origin/task1 </li></ul><ul><li>$ git fetch origin/task1; git merge origin/task1. </li></ul><ul><li>(Git pull == git fetch+git merge). </li></ul><ul><li>After git clone mymobility. </li></ul><ul><li>After some duration of time this repo may not be up to date,so fetch an update. </li></ul><ul><li>git fetch origin </li></ul>
    25. 28. <ul><li>After the fetch, task1 will be different. ‘origin/ task1 ’ will now point to one of the new commit objects downloaded during the fetch. </li></ul><ul><li>we can merge ‘origin/ task1 ’ into our local ‘ task1 ’ branch. </li></ul><ul><li>The above two operations are equivalent to </li></ul><ul><li>git pull origin/task1 </li></ul>
    26. 29. <ul><li>git push </li></ul><ul><li>To push the changes to other repositories. </li></ul><ul><li>Git push is possible only when you have commit rights on the repo.(usually over ssh) </li></ul><ul><li>git push experiment master </li></ul><ul><li>Push the changes in the experiment branch to the remote master branch </li></ul>
    27. 30. <ul><li>Git help </li></ul><ul><li>git [command] –help </li></ul><ul><li>git help [command] </li></ul><ul><li>Daily Usage commands </li></ul><ul><li>git init git clone git add git commit </li></ul><ul><li>git branch git checkout git merge git remote </li></ul><ul><li>git fetch git push git diff git log </li></ul>
    28. 31. <ul><li>GitHub offers both commercial plans and free accounts for open source projects that use git. </li></ul><ul><li>GitHub offers social networking functionality like feeds, followers and the network graph to display how developers work. </li></ul><ul><li>Gitorious provides open source infrastructure for hosting open source projects that use Git. </li></ul><ul><li>Gitorious also offers most of the features that are offered through the github. </li></ul>
    29. 32. <ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li>#git / #github on IRC </li></ul><ul><li>A Tutorial Introduction to Git ( ) </li></ul><ul><li>Note:-All the commands(git or os specific) in the presentation are in a lowercase comapred to the normal text. </li></ul>
    30. 33. Thankyou Satyendra.Jaladi