SlideShare ist ein Scribd-Unternehmen logo
1 von 56
Downloaden Sie, um offline zu lesen
Git Introduction
1
為什麼要做版本控制??
2
LocalVersion Control Systems
• 在自己電腦裡,建立⼀一
個版本資料庫
• 最簡單的作法
Problem:如何協作??
3
CentralizedVersion Control Systems
• Server上,會儲存所有的
版本及記錄
• Checkout & Commit
4
DistributedVersion Control Systems
• 大家都有完整的資料庫
• 大家都能獨立工作
• Server壞了只要拿到⼀一份
完整的資料庫便可復原
• Git, Mecurial(hg),
bazaar(bzr)
Problem:相較於Centralized
混亂。
提供好的Branch機制解決
此問題。
5
https://help.github.com/articles/set-up-git
6
Set up Git
https://help.github.com/articles/set-up-git
7
$ git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit
$ git config --global user.email "your_email@youremail.com"
# Sets the default email for git to use when you commit
$ git credential-osxkeychain
# Test for the cred helper
Usage: git credential-osxkeychain <get|store|erase>
8
$ git credential-osxkeychain
# Test for the cred helper
git: 'credential-osxkeychain' is not a git command. See 'git
--help'.
$ curl -s -O http://github-media-downloads.s3.amazonaws.com/
osx/git-credential-osxkeychain
# Download the helper
$ chmod u+x git-credential-osxkeychain
# Fix the permissions on the file so it can be run
$ sudo mv git-credential-osxkeychain /usr/local/git/bin
# Move the file so git can access it
# Password: [enter your password]
9
$ git config --global credential.helper osxkeychain
# Set git to use the osxkeychain credential helper
10
Get a Github account
https://github.com/
11
https://help.github.com/articles/generating-ssh-keys
Generate SSH Keys
12
$ cd ~/.ssh
$ ls
config id_rsa id_rsa.pub known_hosts
$ mkdir key_backup
$ cp id_rsa* key_backup
$ rm id_rsa*
$ ssh-keygen -t rsa -C "your_email@youremail.com"
# Creates a new ssh key using the provided email
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/you/.ssh/id_rsa):
[Press enter]
Enter passphrase (empty for no passphrase): [Type a
passphrase]
Enter same passphrase again: [Type passphrase again]
Your identification has been saved in /Users/you/.ssh/id_rsa.
Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db
your_email@youremail.com
13
$ pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
14
$ ssh -T git@github.com
# Attempts to ssh to github
The authenticity of host 'github.com (207.97.227.239)' can't
be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:
56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
Hi username! You've successfully authenticated, but GitHub
does not provide shell access.
15
Create a Repo
16
17
18
$ mkdir ~/Hello-World
# Creates a directory for your project called "Hello-World"
in your user directory
$ cd ~/Hello-World
# Changes the current working directory to your newly
created directory
$ git init
# Sets up the necessary Git files
Initialized empty Git repository in /Users/you/Hello-
World/.git/
$ touch README
# Creates a file called "README" in your Hello-World
directory
19
$ git add README
# Stages your README file, adding it to the list of files to
be committed
$ git commit -m 'first commit'
# Commits your files, adding the message "first commit"
$ git remote add origin https://github.com/username/Hello-
World.git
# Creates a remote named "origin" pointing at your GitHub
repo
$ git push origin master
# Sends your commits in the "master" branch to GitHub
20
Fork A Repo
$ git clone git@github.com:oboegrace/git-101.git
https://help.github.com/articles/fork-a-repo
21
Git Basics
22
Snapshots, Not Differences
SVN
Git
23
Nearly Every Operation is Local
• 不只有⼀一份完整的資料
庫
• 閱讀版本歷史、提交
變更這些動作都可以
在本機進行
• 不需網路連線也可以工
作
24
Git Has Integrity
• 使用 Checksum 來確保檔案的完整性
• 設計上只會增加資料,因此可以輕鬆復
原
• 在本機的檔案管理中,增添了Staging的
觀念
25
TheThree States of Git
• Committed
• Data is safely stored in your local database.
• Modified
• You have changed the file but have not committed it to your
database yet.
• Staged
• You have marked a modified file in its current version to go
into your next commit snapshot.
26
The basic workflow of Git
1. You modify files in your
working directory.
2. You stage the files,
adding snapshots of
them to your staging
area.
3. You do a commit, which
takes the files as they
are in the staging area
and stores that snapshot
permanently to your Git
directory.
27
Using Git
28
Installing Git
• Installing on Mac
• http://code.google.com/p/git-osx-installer
• Installing on Windows
• http://code.google.com/p/msysgit
29
Initializing a Repository in an Existing Directory
• Repository就是⼀一份版本控制中心的版本
資料庫
• $ git init
• 資訊會放在.git資料夾裡
30
Initial Commit
• Add files
• And commit it!
$ touch README
$ git add .
$ git commit -m 'Initial commit'
31
Cloning an Existing Repository
$ git clone git://github.com/schacon/grit.git
Checking the Status ofYour Files
$ git status
# On branch master
nothing to commit (working directory clean)
Ignoring Files
$ cat .gitignore
*.[oa]
*~
32
CommittingYour Changes
$ git commit
Removing Files
$ git rm grit.gemspec
rm 'grit.gemspec'
$ git status
# On branch master
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: grit.gemspec
#
33
ChangingYour Last Commit
$ git commit --amend
Unstaging a Staged File
$ git reset HEAD aFile
Unmodifying a Modified File
$ git checkout -- aFile
34
Working with Remotes
• Branch 和 Remote 之間的互動
• 預設的 Branch 叫 Master
• 預設的 Remote 叫 Origin
• $ git pull origin :
$ git fetch origin
$ git merge origin/master
• $ git push origin master
push
35
What a Branch Is
36
Single commit repository data.
37
Git object data for multiple commits.
Branch pointing into the commit data’s history.
38
$ git branch testing
git branch <new_branch_name> 建立本地 local branch
git branch 列出目前有那些 branch 以及目前在那個 branch
39
$ git checkout testing
This moves HEAD to point to the testing branch
此時如果commit...
git checkout <branch_name> 切換 branch
40
41
$ git checkout master
42
$ git commit -a -m 'made other changes'
43
http://learn.github.com/p/branching.html
Practice Branching and Merging
44
如何重新變回⼀一條?
• Merge
• 把岔開來的分支在往後合起來
• 通常的建議方式
• Rebase
• 把岔開來的分支裝回去主線
• 還沒Push出去的東西才可以Rebase!
45
Basic Branching and Merging
46
有緊急的Bug,開了一個 hotfix branch 處理好了。
現在要怎麼處理 master?
47
$ git checkout master
$ git merge hotfix
48
此時處理完iss53,那該如何Merge?
49
$ git checkout master
$ git merge iss53
50
Basic Merge Conflicts
• git status ⼀一下看是哪個檔案出問題
• 到出問題的檔案找問題,手動解決
• 再檢查 git status 後,用 git commit 手動
Merge (會自動生成 Merge 的 Commit Message)
51
Rebase
52
除了Merge以外,我有沒有其他的辦法可以處理
掉 experiment branch?
53
$ git checkout experiment
$ git rebase master
54
$ git checkout master
$ git merge experiment
55
$ git clone git@github.com:oboegrace/git-101.git
Let’s practice it!
1. Set up git https://help.github.com/articles/set-up-git
2. Generate SSH Keys https://help.github.com/articles/generating-ssh-keys
3. Create a repo https://help.github.com/articles/create-a-repo
4. Fork a repo https://help.github.com/articles/fork-a-repo
5. Be social https://help.github.com/articles/be-social
6. Normal Workflow http://learn.github.com/p/normal.html
7. Branching and merging http://learn.github.com/p/branching.html
8. Distributed Git http://learn.github.com/p/remotes.html
9. Git history http://learn.github.com/p/log.html
10.Git reference http://gitref.org/
Reference
56

Weitere ähnliche Inhalte

Was ist angesagt?

Deep dark-side of git: How git works internally
Deep dark-side of git: How git works internallyDeep dark-side of git: How git works internally
Deep dark-side of git: How git works internallySeongJae Park
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)bryanbibat
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use ItDaniel Kummer
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advancedYodalee
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Codemotion
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of GitDivineOmega
 
From svn to git
From svn to gitFrom svn to git
From svn to gitNehal Shah
 
Introduction to Git / Github
Introduction to Git / GithubIntroduction to Git / Github
Introduction to Git / GithubPaige Bailey
 

Was ist angesagt? (20)

Git Real
Git RealGit Real
Git Real
 
Deep dark-side of git: How git works internally
Deep dark-side of git: How git works internallyDeep dark-side of git: How git works internally
Deep dark-side of git: How git works internally
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Git training
Git trainingGit training
Git training
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
 
Git & Github for beginners
Git & Github for beginnersGit & Github for beginners
Git & Github for beginners
 
Bitbucket
BitbucketBitbucket
Bitbucket
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git internals
Git internalsGit internals
Git internals
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
From svn to git
From svn to gitFrom svn to git
From svn to git
 
Introduction to Git / Github
Introduction to Git / GithubIntroduction to Git / Github
Introduction to Git / Github
 
Git github
Git githubGit github
Git github
 

Ähnlich wie 簡單介紹git

Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITMgdsc13
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Brian K. Vagnini
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
 
Learning git
Learning gitLearning git
Learning gitSid Anand
 
Gitting It Under (Version) Control
Gitting It Under (Version) ControlGitting It Under (Version) Control
Gitting It Under (Version) Controlmobiledevnj
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about gitSothearin Ren
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlBecky Todd
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in UnityRifauddin Tsalitsy
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.comdropsolid
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With GitHoffman Lab
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthroughBimal Jain
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmdsrinathcox
 

Ähnlich wie 簡單介紹git (20)

390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
 
Git101
Git101Git101
Git101
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git training v10
Git training v10Git training v10
Git training v10
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Learning git
Learning gitLearning git
Learning git
 
Gitting It Under (Version) Control
Gitting It Under (Version) ControlGitting It Under (Version) Control
Gitting It Under (Version) Control
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
 
git.ppt.pdf
git.ppt.pdfgit.ppt.pdf
git.ppt.pdf
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
 
Git
GitGit
Git
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 

Kürzlich hochgeladen

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Kürzlich hochgeladen (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

簡單介紹git

  • 3. LocalVersion Control Systems • 在自己電腦裡,建立⼀一 個版本資料庫 • 最簡單的作法 Problem:如何協作?? 3
  • 4. CentralizedVersion Control Systems • Server上,會儲存所有的 版本及記錄 • Checkout & Commit 4
  • 5. DistributedVersion Control Systems • 大家都有完整的資料庫 • 大家都能獨立工作 • Server壞了只要拿到⼀一份 完整的資料庫便可復原 • Git, Mecurial(hg), bazaar(bzr) Problem:相較於Centralized 混亂。 提供好的Branch機制解決 此問題。 5
  • 8. $ git config --global user.name "Your Name Here" # Sets the default name for git to use when you commit $ git config --global user.email "your_email@youremail.com" # Sets the default email for git to use when you commit $ git credential-osxkeychain # Test for the cred helper Usage: git credential-osxkeychain <get|store|erase> 8
  • 9. $ git credential-osxkeychain # Test for the cred helper git: 'credential-osxkeychain' is not a git command. See 'git --help'. $ curl -s -O http://github-media-downloads.s3.amazonaws.com/ osx/git-credential-osxkeychain # Download the helper $ chmod u+x git-credential-osxkeychain # Fix the permissions on the file so it can be run $ sudo mv git-credential-osxkeychain /usr/local/git/bin # Move the file so git can access it # Password: [enter your password] 9
  • 10. $ git config --global credential.helper osxkeychain # Set git to use the osxkeychain credential helper 10
  • 11. Get a Github account https://github.com/ 11
  • 13. $ cd ~/.ssh $ ls config id_rsa id_rsa.pub known_hosts $ mkdir key_backup $ cp id_rsa* key_backup $ rm id_rsa* $ ssh-keygen -t rsa -C "your_email@youremail.com" # Creates a new ssh key using the provided email Generating public/private rsa key pair. Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter] Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again] Your identification has been saved in /Users/you/.ssh/id_rsa. Your public key has been saved in /Users/you/.ssh/id_rsa.pub. The key fingerprint is: 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@youremail.com 13
  • 14. $ pbcopy < ~/.ssh/id_rsa.pub # Copies the contents of the id_rsa.pub file to your clipboard 14
  • 15. $ ssh -T git@github.com # Attempts to ssh to github The authenticity of host 'github.com (207.97.227.239)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b: 56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? Hi username! You've successfully authenticated, but GitHub does not provide shell access. 15
  • 17. 17
  • 18. 18
  • 19. $ mkdir ~/Hello-World # Creates a directory for your project called "Hello-World" in your user directory $ cd ~/Hello-World # Changes the current working directory to your newly created directory $ git init # Sets up the necessary Git files Initialized empty Git repository in /Users/you/Hello- World/.git/ $ touch README # Creates a file called "README" in your Hello-World directory 19
  • 20. $ git add README # Stages your README file, adding it to the list of files to be committed $ git commit -m 'first commit' # Commits your files, adding the message "first commit" $ git remote add origin https://github.com/username/Hello- World.git # Creates a remote named "origin" pointing at your GitHub repo $ git push origin master # Sends your commits in the "master" branch to GitHub 20
  • 21. Fork A Repo $ git clone git@github.com:oboegrace/git-101.git https://help.github.com/articles/fork-a-repo 21
  • 24. Nearly Every Operation is Local • 不只有⼀一份完整的資料 庫 • 閱讀版本歷史、提交 變更這些動作都可以 在本機進行 • 不需網路連線也可以工 作 24
  • 25. Git Has Integrity • 使用 Checksum 來確保檔案的完整性 • 設計上只會增加資料,因此可以輕鬆復 原 • 在本機的檔案管理中,增添了Staging的 觀念 25
  • 26. TheThree States of Git • Committed • Data is safely stored in your local database. • Modified • You have changed the file but have not committed it to your database yet. • Staged • You have marked a modified file in its current version to go into your next commit snapshot. 26
  • 27. The basic workflow of Git 1. You modify files in your working directory. 2. You stage the files, adding snapshots of them to your staging area. 3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory. 27
  • 29. Installing Git • Installing on Mac • http://code.google.com/p/git-osx-installer • Installing on Windows • http://code.google.com/p/msysgit 29
  • 30. Initializing a Repository in an Existing Directory • Repository就是⼀一份版本控制中心的版本 資料庫 • $ git init • 資訊會放在.git資料夾裡 30
  • 31. Initial Commit • Add files • And commit it! $ touch README $ git add . $ git commit -m 'Initial commit' 31
  • 32. Cloning an Existing Repository $ git clone git://github.com/schacon/grit.git Checking the Status ofYour Files $ git status # On branch master nothing to commit (working directory clean) Ignoring Files $ cat .gitignore *.[oa] *~ 32
  • 33. CommittingYour Changes $ git commit Removing Files $ git rm grit.gemspec rm 'grit.gemspec' $ git status # On branch master # # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: grit.gemspec # 33
  • 34. ChangingYour Last Commit $ git commit --amend Unstaging a Staged File $ git reset HEAD aFile Unmodifying a Modified File $ git checkout -- aFile 34
  • 35. Working with Remotes • Branch 和 Remote 之間的互動 • 預設的 Branch 叫 Master • 預設的 Remote 叫 Origin • $ git pull origin : $ git fetch origin $ git merge origin/master • $ git push origin master push 35
  • 36. What a Branch Is 36
  • 38. Git object data for multiple commits. Branch pointing into the commit data’s history. 38
  • 39. $ git branch testing git branch <new_branch_name> 建立本地 local branch git branch 列出目前有那些 branch 以及目前在那個 branch 39
  • 40. $ git checkout testing This moves HEAD to point to the testing branch 此時如果commit... git checkout <branch_name> 切換 branch 40
  • 41. 41
  • 42. $ git checkout master 42
  • 43. $ git commit -a -m 'made other changes' 43
  • 45. 如何重新變回⼀一條? • Merge • 把岔開來的分支在往後合起來 • 通常的建議方式 • Rebase • 把岔開來的分支裝回去主線 • 還沒Push出去的東西才可以Rebase! 45
  • 46. Basic Branching and Merging 46
  • 47. 有緊急的Bug,開了一個 hotfix branch 處理好了。 現在要怎麼處理 master? 47
  • 48. $ git checkout master $ git merge hotfix 48
  • 50. $ git checkout master $ git merge iss53 50
  • 51. Basic Merge Conflicts • git status ⼀一下看是哪個檔案出問題 • 到出問題的檔案找問題,手動解決 • 再檢查 git status 後,用 git commit 手動 Merge (會自動生成 Merge 的 Commit Message) 51
  • 54. $ git checkout experiment $ git rebase master 54
  • 55. $ git checkout master $ git merge experiment 55
  • 56. $ git clone git@github.com:oboegrace/git-101.git Let’s practice it! 1. Set up git https://help.github.com/articles/set-up-git 2. Generate SSH Keys https://help.github.com/articles/generating-ssh-keys 3. Create a repo https://help.github.com/articles/create-a-repo 4. Fork a repo https://help.github.com/articles/fork-a-repo 5. Be social https://help.github.com/articles/be-social 6. Normal Workflow http://learn.github.com/p/normal.html 7. Branching and merging http://learn.github.com/p/branching.html 8. Distributed Git http://learn.github.com/p/remotes.html 9. Git history http://learn.github.com/p/log.html 10.Git reference http://gitref.org/ Reference 56