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

More Related Content

What's hot

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
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
 

What's hot (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
 

Similar to 簡單介紹git

390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
Nguyen Van Hung
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
UshaSuray
 
Git101
Git101Git101
Git101
Jens Segers
 
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 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
 
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) Controlmobiledevnj
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
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
 
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
GitGit
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Bimal Jain
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
srinathcox
 

Similar to 簡單介紹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
 

Recently uploaded

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 

簡單介紹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