Introduction to Git

1,227 views

Published on

Git - Introduction and Exercises
National Chengchi University
LittleQ

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,227
On SlideShare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
23
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Introduction to Git

  1. 1. Introduction to Git Version Control System
  2. 2. Who am I• LittleQ, junior student@ NCCUCS• Software engineer @ Genie Capital• Co-organizer @ Taipei Google Tech User Group• Instructor @ Geego system, Inc• http://about.me/littleq• Python, Linux and everything geeky! Git Introduction Version Control System
  3. 3. What is Git• Version control system• Coding history• Distributed version control Git Introduction Version Control System
  4. 4. Version False True commit  296fad37b4e3e78bd952d419625d87f52a3d52d4 Diablo I Merge:  e5fb1da  fe68f70 Author:  Jacob  Thornton  <jacobthornton@gmail.com> Date:      Thu  Nov  24  11:13:33  2011  -­‐0800 Diablo II        新增⼀一行很重要的code,把bug給修好了!Diablo III (5/15) commit  fe68f708ce723cef640c1cf784cb29da513bca22 Starcraft I Author:  Martin  Bean  <martin@mcbwebdesign.co.uk> Date:      Thu  Nov  24  19:06:00  2011  +0000 Starcraft II        樓上對不起!我不小心把你code給砍了=  = Git Introduction Version Control System
  5. 5. Why Git• Maintenance• Debug• Responsibility Git Introduction Version Control System
  6. 6. History• Developed by Linus Torvalds• Born for improving the development of Linux Kernel Git Introduction Version Control System
  7. 7. Who need Git• Real Engineer• Engineers who is working with thousands of thousands of lines of code• Wanna being a contributor of open source projects Git Introduction Version Control System
  8. 8. Requirement Git Introduction Version Control System
  9. 9. Scenario• Team work• Code management Git Introduction Version Control System
  10. 10. Terminology• commit• stage• repository Git Introduction Version Control System
  11. 11. Commitcommit bf74427f03bc80927f97755772d87e579604cf35 commit 72da1eb5da5596432b0b36534169756f44bae70f commit a9718b877b45f987502357204fdbe0ec7599b46c Git Introduction Version Control System
  12. 12. Commitcommit inside: diff  -­‐-­‐git  a/omgtt/configs/staging/settings.py  b/omgtt/configs/ staging/settings.py index  a17ad10..932c66a  100644 -­‐-­‐-­‐  a/omgtt/configs/staging/settings.py +++  b/omgtt/configs/staging/settings.py @@  -­‐10,7  +10,7  @@  ADMIN_MEDIA_PREFIX  =  /static/admin/  DOWNLOAD_DIRECTORY  =  /tmp/    SITE_DOMAIN  =  omg.demo.gd:3377 +SITE_ID  =  4ef4509316d5ad652a00001c -­‐SITE_ID  =        INTERNAL_IPS  =  () Git Introduction Version Control System
  13. 13. Let’s rock! Git Introduction Version Control System
  14. 14. Steps• Install Git• Setup Git• Initialize your first local repository• Commit, commit and commit! Git Introduction Version Control System
  15. 15. Install Git• In Linux, it is just a piece of cake• In Windows, google it Git Introduction Version Control System
  16. 16. Using Git on ghost• For using the latest version of git: `export  PATH=”/opt/csw/bin:$PATH”`• Write it down in your ~/.profile• And login again Git Introduction Version Control System
  17. 17. Setup Git• Username git config --global user.name “LittleQ”• Email git config --global user.email “your email” Git Introduction Version Control System
  18. 18. Repo init• Get into your project’s root directory• `git init`• `git add .`• `git commit -m “first commit”` Git Introduction Version Control System
  19. 19. Commit• the basic unit of modified records• changes can be on single file or multiple files• can be deleting files or adding files Git Introduction Version Control System
  20. 20. Make a commit• Make the modifications• `git status`• `git add <modified-files>`• `git commit -m “message”` Git Introduction Version Control System
  21. 21. Push & Pull• Push: send your modifications to the server• Pull: receive the modifications from others• `git pull`• `git push origin master` Git Introduction Version Control System
  22. 22. Clone a Repo• git clone <git-repo-url> Git Introduction Version Control System
  23. 23. Github• A social website of engineers (Engineering version Facebook)• Easy to manage your git repo• Socialize your work Git Introduction Version Control System
  24. 24. Exercise• Here we are going to create a repo and build a simple Hello World program on it• We won’t do much programming stuff, so please concentrate• Now pick up 3 members (Included yourself ) to form a group goo.gl/C2vFG Git Introduction Version Control System
  25. 25. Sign Up• Just go to sign up an account on Github• Find out the profile page of your teammates and follow them on github• Choose one as the leader and the one need to create a repo and add others members as the repo members Git Introduction Version Control System
  26. 26. Create a Repo and Push to Server• mkdir teamXX; cd teamXX;• git init• git remote add origin <url-of-repo>• git add .• git commit -m “first commit”• git push origin master Git Introduction Version Control System
  27. 27. Prototype of HW cp  /usr/local/class/mathcp/materials/git  ~/TeamXX#  comments#  teamXX#  99XXXXXX,  99XXXXXX,  99XXXXXXfunction  hello1()  { print(“hello,  member1’s  name”);}function  hello2()  { print(“hello,  member2’s  name”);}function  hello3()  {    print(“hello,  member2’s  name”);}function  main()  {    hello1();    hello2();    hello3();} Git Introduction Version Control System
  28. 28. Notice• Each function can only be completed by one and different from others• Need to push onto github• If someone got stuck, help each other Git Introduction Version Control System
  29. 29. And More...• Branch• Merge• Remote Git Introduction Version Control System
  30. 30. Repository Hosting• Google Code (free)• Github (free)• Bitbucket (free, private repo)• unfuddle• repositoryhosting Git Introduction Version Control System
  31. 31. Resource• Git http://git-scm.com/• Github help http://help.github.com/• iHower blog http://ihower.tw/blog/posts > Git category Git Introduction Version Control System
  32. 32. The End Git Introduction Version Control System

×