git tutorial i
DESCRIPTION
Git TutorialTRANSCRIPT
![Page 2: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/2.jpg)
About Me
• Full-stack Engineer
• Python since 2006 Javascript since 2010 Git since 2011
![Page 3: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/3.jpg)
• Introduction
• Hands on Git
• Local repository
• Remote repository
Hackpad: http://tinyurl.com/nccumath-git
Outline
![Page 4: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/4.jpg)
What is Git?
• Source Code Management system (SCM)
• Distributed Version Control System (DVCS)
• Created by Linus Torvalds
![Page 5: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/5.jpg)
Why Git?
• Collaboration
• Version control
• Track development history
• Distributed
• Not only source code
![Page 6: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/6.jpg)
Setup environment
• On ubuntu, apt-get install git
• On mac, brew install git or use git-scm for mac
• On windows, use git-scm for windows
![Page 7: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/7.jpg)
Repository
• A project
• Local and Remote
![Page 8: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/8.jpg)
Clone a Repository
• git clone <repo path>
• git status
Local Remotegit clone
![Page 9: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/9.jpg)
Log
• Display commit records
• git log --color --graph --all --decorate
![Page 10: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/10.jpg)
Exercise 1
• Clone the following project: https://github.com/nccumath/git-exercise-1.git
• Check its status.
![Page 11: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/11.jpg)
Local Repository
![Page 12: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/12.jpg)
Config
• git config --global user.name "Jim Yeh"
• git config --global user.email “[email protected]”
• git config --global core.editor "notepad++.exe -multiInst"
• git config --global -l
![Page 13: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/13.jpg)
Phases
• Workspace (unstaged) - Update documents.
• Staging Area (staged)- Ready for submit (commit).
• Repository (committed) - Submitted.
Workspace Staging Area
Local Repository
![Page 14: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/14.jpg)
Submit your code
• git add <filename>
• git reset HEAD <filename>
• git commit
![Page 15: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/15.jpg)
Submit your code
• git add <filename>
• git reset HEAD <filename>
• git commit
Stage
![Page 16: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/16.jpg)
Submit your code
• git add <filename>
• git reset HEAD <filename>
• git commit
Stage
Unstage
![Page 17: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/17.jpg)
Submit your code
• git add <filename>
• git reset HEAD <filename>
• git commit
Stage
Unstage
Commit
![Page 18: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/18.jpg)
Commit number
• ID number for each commit
• Use for many configuration
![Page 19: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/19.jpg)
Local Workflow
Workspace Staging Area
Local Repository
git add
git commit
git rest HEAD
![Page 20: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/20.jpg)
Examine changes
• Check difference between two commit by git diff
• git diff <old-commit> <new-commit>
![Page 21: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/21.jpg)
Exercise 2
• Add a new file named to your SID.
• Commit the file.
![Page 22: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/22.jpg)
Branch
• There is at least one branch in a repository.
• Default branch is called master branch
![Page 23: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/23.jpg)
Branch operation
• git branch
• git branch <branch name>
• git checkout <branch name>
![Page 24: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/24.jpg)
Exercise 3
• Create a branch in your SID
• Checkout to that branch
• Update introduction.txt
• Commit your update
![Page 25: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/25.jpg)
Keyword Review
![Page 26: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/26.jpg)
Noun
• Repository
• Branch
• Commit
![Page 27: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/27.jpg)
Noun
• Repository
• Branch
• Commit Dot
![Page 28: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/28.jpg)
Noun
• Repository
• Branch
• Commit
Line
Dot
![Page 29: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/29.jpg)
Noun
• Repository
• Branch
• Commit
Line
Dot
Surface
![Page 30: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/30.jpg)
Noun
• Repository
• Branch
• Commit
Line
Dot
Surface
![Page 31: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/31.jpg)
Noun
• Repository
• Branch
• Commit
Line
Dot
Surface Tree
![Page 32: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/32.jpg)
Verb
Stage
Unstage
Commit
![Page 33: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/33.jpg)
Remote
![Page 34: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/34.jpg)
GitHub
• http://www.github.com
• A web-based hosting service for Git
• Provide a platform for comments, wiki and issue tracking.
![Page 35: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/35.jpg)
Sign up
![Page 36: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/36.jpg)
Remote Info
• git remote
• git remote show
• git remote add <name> <url>
![Page 37: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/37.jpg)
Push / Pull
• git push <remote> <branch>
• git pull <remote> <branch>Local Remote
git push
git pull
![Page 38: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/38.jpg)
Exercise 4
• Push your branch to remote.
![Page 39: Git Tutorial I](https://reader034.vdocument.in/reader034/viewer/2022052217/558de5e51a28abef428b4776/html5/thumbnails/39.jpg)
Q & A