SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (20)

Git Real
Git RealGit Real
Git Real
Gong Haibing
 
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
SeongJae 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 It
Daniel Kummer
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
Yodalee
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
Bioinformatics and Computational Biosciences Branch
 
Git real slides
Git real slidesGit real slides
Git real slides
Lucas Couto
 
Git training
Git trainingGit training
Git training
adm_exoplatform
 
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
Codemotion
 
Git & Github for beginners
Git & Github for beginnersGit & Github for beginners
Git & Github for beginners
Paulo Henrique Nonaka
 
Bitbucket
BitbucketBitbucket
Bitbucket
hariprasad1035
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
Arulmurugan Rajaraman
 
Git internals
Git internalsGit internals
Git internals
Haggai Philip Zagury
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
DivineOmega
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
Pham Quy (Jack)
 
From svn to git
From svn to gitFrom svn to git
From svn to git
Nehal Shah
 
Introduction to Git / Github
Introduction to Git / GithubIntroduction to Git / Github
Introduction to Git / Github
Paige Bailey
 
Git github
Git githubGit github
Git github
Anurag Deb
 
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
SeongJae 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 It
Daniel Kummer
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
Yodalee
 
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
Codemotion
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
DivineOmega
 
From svn to git
From svn to gitFrom svn to git
From svn to git
Nehal Shah
 
Introduction to Git / Github
Introduction to Git / GithubIntroduction to Git / Github
Introduction to Git / Github
Paige Bailey
 

Similar to 簡單介紹git (20)

390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
Nguyen Van Hung
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
UshaSuray
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
gdsc13
 
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
Brian 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
 
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
Learning git
Learning gitLearning git
Learning git
Sid Anand
 
Gitting It Under (Version) Control
Gitting It Under (Version) ControlGitting It Under (Version) Control
Gitting It Under (Version) Control
mobiledevnj
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
git.ppt.pptx power point presentation got Google internet
git.ppt.pptx power point presentation got Google internetgit.ppt.pptx power point presentation got Google internet
git.ppt.pptx power point presentation got Google internet
rani marri
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
Sothearin 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 control
Becky Todd
 
github ppt git ppt on git hub to know ab
github ppt git ppt on git hub to know abgithub ppt git ppt on git hub to know ab
github ppt git ppt on git hub to know ab
infoinnext
 
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
Rifauddin Tsalitsy
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
dropsolid
 
git.ppt.pdf
git.ppt.pdfgit.ppt.pdf
git.ppt.pdf
Roniel Lopez Alvarez
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
Hoffman Lab
 
Git
GitGit
Git
Gayan Kalanamith Mannapperuma
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Bimal Jain
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
gdsc13
 
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
Brian 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 git
Sid Anand
 
Gitting It Under (Version) Control
Gitting It Under (Version) ControlGitting It Under (Version) Control
Gitting It Under (Version) Control
mobiledevnj
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
git.ppt.pptx power point presentation got Google internet
git.ppt.pptx power point presentation got Google internetgit.ppt.pptx power point presentation got Google internet
git.ppt.pptx power point presentation got Google internet
rani marri
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
Sothearin 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 control
Becky Todd
 
github ppt git ppt on git hub to know ab
github ppt git ppt on git hub to know abgithub ppt git ppt on git hub to know ab
github ppt git ppt on git hub to know ab
infoinnext
 
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
Rifauddin Tsalitsy
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
dropsolid
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
Hoffman Lab
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Bimal Jain
 
Ad

Recently uploaded (20)

Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Ad

簡單介紹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 "[email protected]" # 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 "[email protected]" # 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 [email protected] 13
  • 14. $ pbcopy < ~/.ssh/id_rsa.pub # Copies the contents of the id_rsa.pub file to your clipboard 14
  • 15. $ ssh -T [email protected] # 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 [email protected]: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 [email protected]: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