狠狠撸

狠狠撸Share a Scribd company logo
Git Basics
Gitlab X SourceTree
Tom Chen <tom@ifp.io>
第一次安裝
產生金鑰 (SSH Key)
? 讓 Gitlab 認得你的電腦
? 一台電腦只需要做一次
? 產生一組 SSH 的 public/private Key
? 給 Gitlab public key, 配合自己電腦的 private key 就可以驗證 ok
? Tools ? Create or Import SSH Keys
? 按下 Generate 在空白的地方随便移动滑鼠来製造乱数
? 儲存 private key (Save Private Key), 隨便儲存一個檔名 (.ppk)
存檔的時候會問你
是否真的不要在每次存取金鑰的時候
用一個密碼保護?
如果你想要安全一點, 就設定一個密碼,
填在左圖中 Key passphrase 跟 Confirm passphrase 中
或者不要的話就… 以可以啦 orz
? 匯入 Public Key 到 Gitlab
Copy 這整段
點選 Profile Settings
點選 SSH Keys
點選 Add SSH Key
2. 剛剛 Copy 的貼上
1. 給個名字, 譬如 Work Machine (工作機) 之類的
3. 按下 Add Key, Gitlab 這邊匯入就大功告成
設定名稱跟 E-mail
2. 填寫你的全名跟 E-mail1. 去到 Tools -> Options
產生一個新的 Repository
點選 New Project
取一個好的名字, 通常全部小寫, 中間用 - 隔開
記得選 ifp (我們自己的 group)
預設就是 Private 就不用改了
最後按下 Create Project
最重要的就是这个网址了!!
按下 Clone / New
1. 貼上
3. 按下 Clone
2. 選好你希望他在本機端的哪個資料夾中
TADA!!!
新增档案
? 假設本地端目錄在 C:UsersUserMy Documentstest-project
? 到這個目錄底下建立一些檔案
? 例如: test.txt, 打一些字並且存檔
還沒有被追蹤版本控管的檔案
按下 Add 把沒有被追蹤的加入版本控管
Gitlab
1. 按下 Commit 把這一次的變更編入版本控管
寫下這一次變更的註解
2. 按下 Commit 確認
按下 Push 把變更推到伺服器上
推到伺服器的 master 分支
這時候再去 Gitlab 的 Files 查看就看得到變更了!!
变更档案
? 把剛才的 test.txt 更改一些內容
? 隨便新增一個檔案
SourceTree 會自動偵測變更
按下 Add 把目前的變更加入
1. 按下 Commit
2. 寫下這一次
變更的註解
3. 這邊打勾的話, 就可
以直接 Commit 的時候
順便 Push 到伺服器上
4. 按下 Commit 確認
在 Gitlab 的 Commits 可以看到每次變更的內容
拉變更 (pull)
? Repository 並不是只有你一個人在使用
? 也有可能有別人做了變更
? 你需要拉別人的變更下來 (pull)
Gitlab
Gitlab
Gitlab
Workflow
1. 從 Server Pull 下來
2. 按照原本的作業方式修改檔案, 新增档案… 等等
3. 變更後的東西都在 Unstaged files, 把這一次的批次變更的檔案放到
Staged files
4. 進行 Commit 並且寫下這一次變更的註解
5. Push 到 Server
3 跟 4 可以用 Checkbox 勾選的方式一次一起做
也可以做了一大堆 1-3 之後再一次做 4 把一堆 push 到 server
.gitignore
? 如果是程式專案, 通常會從程式專案的目錄整個進到 git
? 但是有些檔案通常不會進到 repository, 例如
? 編譯後的檔案 (.o, .obj, .so, .lib, .dll, .pyc, …)
? 暫存檔 (.swp)
? 外掛套件 (node_modules)
? 某些設定檔
.gitignore
? 只要在 .gitignore 設定的就會被 git 忽略
? 說明文件
http://git-scm.com/docs/gitignore
? 打入關鍵字幫你產生 .gitignore 的服務
https://www.gitignore.io/
? github 上的 .gitignore 設定
https://github.com/github/gitignore
安全性
? 帳號密碼千萬別加到 repository
? Auth Key 也不要
? Cookie Secret 或任何 secret 類的都不要進到 repository
Markdown
同場加映
到 Wiki
Gitlab
? 內部用的文件別再用 Word 了
? 大家都編輯會有很多 Copy, 散落各處 (Google Docs 可解決)
? 超級難做出一致與精美的樣式
? 一直用滑鼠在調整字形大小、顏色…
? Markdown 只要依照他簡易的格式 + 別人寫好的樣式
? 看起來很乾淨
? 類似網頁有超連結的概念
? GitLab 裡頭還可以指向特定的檔案、程式碼的某一行或者是 Issue
? 版本控管
? https://gitlab.com/help/markdown/markdown
? 另外一個 Popular 的格式 reStructuredText (rst)
? http://sphinx-doc.org/rest.html
? 最後, 一個小分享
每週分享: 如何寫好程式碼的「Commit Message」?
https://passionbean.wordpress.com/2012/02/22/why-good-commit-
message/
? 版本控管使用方式很多種, 如果大家都有共識 follow 共同的方式
對大家來說會輕鬆很多 :D

More Related Content

What's hot (20)

Git與source tree 基礎教學
Git與source tree 基礎教學Git與source tree 基礎教學
Git與source tree 基礎教學
Duncan Chen
?
開發用不著打一架 - 分散式版本控制 Git
開發用不著打一架 - 分散式版本控制 Git開發用不著打一架 - 分散式版本控制 Git
開發用不著打一架 - 分散式版本控制 Git
Calvin Huang
?
A successful git branching model 導讀
A successful git branching model 導讀A successful git branching model 導讀
A successful git branching model 導讀
Wen Liao
?
初心者 Git 上手攻略
初心者 Git 上手攻略初心者 Git 上手攻略
初心者 Git 上手攻略
Lucien Lee
?
惭别谤肠耻谤颈补濒介绍与教学
惭别谤肠耻谤颈补濒介绍与教学惭别谤肠耻谤颈补濒介绍与教学
惭别谤肠耻谤颈补濒介绍与教学
芳本 林
?
Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀
Wen-Tien Chang
?
Yet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom upYet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom up
Wen-Tien Chang
?
Git and git hub
Git and git hubGit and git hub
Git and git hub
唯 李
?
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Bo-Yi Wu
?
寫給大家的 Git 教學
寫給大家的 Git 教學寫給大家的 Git 教學
寫給大家的 Git 教學
littlebtc
?
Git & Sourcetree 介紹
Git & Sourcetree 介紹Git & Sourcetree 介紹
Git & Sourcetree 介紹
Adison wu
?
git, repo, Gerrit 基礎教學
git, repo, Gerrit 基礎教學git, repo, Gerrit 基礎教學
git, repo, Gerrit 基礎教學
Doremi Lin
?
骋颈迟基础介绍
骋颈迟基础介绍骋颈迟基础介绍
骋颈迟基础介绍
Max Ma
?
git merge 與 rebase 的觀念與實務應用
git merge 與 rebase 的觀念與實務應用git merge 與 rebase 的觀念與實務應用
git merge 與 rebase 的觀念與實務應用
Will Huang
?
Git flow 與團隊合作
Git flow 與團隊合作Git flow 與團隊合作
Git flow 與團隊合作
Bo-Yi Wu
?
版本控制 使用Git & git hub
版本控制   使用Git & git hub版本控制   使用Git & git hub
版本控制 使用Git & git hub
維佋 唐
?
Git 經驗分享
Git 經驗分享Git 經驗分享
Git 經驗分享
Mu Chun Wang
?
连哈秋都懂的骋颈迟教学
连哈秋都懂的骋颈迟教学连哈秋都懂的骋颈迟教学
连哈秋都懂的骋颈迟教学
hydai
?
幸福快乐的完美结局
幸福快乐的完美结局幸福快乐的完美结局
幸福快乐的完美结局
Anna Su
?
骋颈迟由超浅入超深
骋颈迟由超浅入超深骋颈迟由超浅入超深
骋颈迟由超浅入超深
羊 小咩 (lamb-mei)
?
Git與source tree 基礎教學
Git與source tree 基礎教學Git與source tree 基礎教學
Git與source tree 基礎教學
Duncan Chen
?
開發用不著打一架 - 分散式版本控制 Git
開發用不著打一架 - 分散式版本控制 Git開發用不著打一架 - 分散式版本控制 Git
開發用不著打一架 - 分散式版本控制 Git
Calvin Huang
?
A successful git branching model 導讀
A successful git branching model 導讀A successful git branching model 導讀
A successful git branching model 導讀
Wen Liao
?
初心者 Git 上手攻略
初心者 Git 上手攻略初心者 Git 上手攻略
初心者 Git 上手攻略
Lucien Lee
?
惭别谤肠耻谤颈补濒介绍与教学
惭别谤肠耻谤颈补濒介绍与教学惭别谤肠耻谤颈补濒介绍与教学
惭别谤肠耻谤颈补濒介绍与教学
芳本 林
?
Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀
Wen-Tien Chang
?
Yet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom upYet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom up
Wen-Tien Chang
?
Git and git hub
Git and git hubGit and git hub
Git and git hub
唯 李
?
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Bo-Yi Wu
?
寫給大家的 Git 教學
寫給大家的 Git 教學寫給大家的 Git 教學
寫給大家的 Git 教學
littlebtc
?
Git & Sourcetree 介紹
Git & Sourcetree 介紹Git & Sourcetree 介紹
Git & Sourcetree 介紹
Adison wu
?
git, repo, Gerrit 基礎教學
git, repo, Gerrit 基礎教學git, repo, Gerrit 基礎教學
git, repo, Gerrit 基礎教學
Doremi Lin
?
骋颈迟基础介绍
骋颈迟基础介绍骋颈迟基础介绍
骋颈迟基础介绍
Max Ma
?
git merge 與 rebase 的觀念與實務應用
git merge 與 rebase 的觀念與實務應用git merge 與 rebase 的觀念與實務應用
git merge 與 rebase 的觀念與實務應用
Will Huang
?
Git flow 與團隊合作
Git flow 與團隊合作Git flow 與團隊合作
Git flow 與團隊合作
Bo-Yi Wu
?
版本控制 使用Git & git hub
版本控制   使用Git & git hub版本控制   使用Git & git hub
版本控制 使用Git & git hub
維佋 唐
?
连哈秋都懂的骋颈迟教学
连哈秋都懂的骋颈迟教学连哈秋都懂的骋颈迟教学
连哈秋都懂的骋颈迟教学
hydai
?
幸福快乐的完美结局
幸福快乐的完美结局幸福快乐的完美结局
幸福快乐的完美结局
Anna Su
?

Viewers also liked (20)

Introduction to Git (part 1)
Introduction to Git (part 1)Introduction to Git (part 1)
Introduction to Git (part 1)
Salvatore Cordiano
?
Git tutorial
Git tutorialGit tutorial
Git tutorial
Elli Kanal
?
真虾意外接到的颁补蝉别
真虾意外接到的颁补蝉别真虾意外接到的颁补蝉别
真虾意外接到的颁补蝉别
Tom Chen
?
Live Performance Effects
Live Performance EffectsLive Performance Effects
Live Performance Effects
Tom Chen
?
Pytables
PytablesPytables
Pytables
gowell
?
Xmas
XmasXmas
Xmas
Tom Chen
?
Command line 初級寶典
Command line 初級寶典Command line 初級寶典
Command line 初級寶典
Tom Chen
?
Elasticsearch intro output
Elasticsearch intro outputElasticsearch intro output
Elasticsearch intro output
Tom Chen
?
Two scoops of django Introduction
Two scoops of django IntroductionTwo scoops of django Introduction
Two scoops of django Introduction
flywindy
?
Two scoops of Django - Deployment
Two scoops of Django - DeploymentTwo scoops of Django - Deployment
Two scoops of Django - Deployment
flywindy
?
AngularJS Sharing
AngularJS SharingAngularJS Sharing
AngularJS Sharing
Tom Chen
?
Django step0
Django step0Django step0
Django step0
永昇 陳
?
Working with the django admin
Working with the django admin Working with the django admin
Working with the django admin
flywindy
?
爱乐工程师
爱乐工程师爱乐工程师
爱乐工程师
Tom Chen
?
Django 實戰 - 自己的購物網站自己做
Django 實戰 - 自己的購物網站自己做Django 實戰 - 自己的購物網站自己做
Django 實戰 - 自己的購物網站自己做
flywindy
?
Integrating tornado and webpack
Integrating tornado and webpackIntegrating tornado and webpack
Integrating tornado and webpack
Tom Chen
?
那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子
flywindy
?
Learning django step 1
Learning django step 1Learning django step 1
Learning django step 1
永昇 陳
?
Django workshop homework 3
Django workshop homework 3Django workshop homework 3
Django workshop homework 3
flywindy
?
解密解密
解密解密解密解密
解密解密
Tom Chen
?
真虾意外接到的颁补蝉别
真虾意外接到的颁补蝉别真虾意外接到的颁补蝉别
真虾意外接到的颁补蝉别
Tom Chen
?
Live Performance Effects
Live Performance EffectsLive Performance Effects
Live Performance Effects
Tom Chen
?
Command line 初級寶典
Command line 初級寶典Command line 初級寶典
Command line 初級寶典
Tom Chen
?
Elasticsearch intro output
Elasticsearch intro outputElasticsearch intro output
Elasticsearch intro output
Tom Chen
?
Two scoops of django Introduction
Two scoops of django IntroductionTwo scoops of django Introduction
Two scoops of django Introduction
flywindy
?
Two scoops of Django - Deployment
Two scoops of Django - DeploymentTwo scoops of Django - Deployment
Two scoops of Django - Deployment
flywindy
?
AngularJS Sharing
AngularJS SharingAngularJS Sharing
AngularJS Sharing
Tom Chen
?
Working with the django admin
Working with the django admin Working with the django admin
Working with the django admin
flywindy
?
爱乐工程师
爱乐工程师爱乐工程师
爱乐工程师
Tom Chen
?
Django 實戰 - 自己的購物網站自己做
Django 實戰 - 自己的購物網站自己做Django 實戰 - 自己的購物網站自己做
Django 實戰 - 自己的購物網站自己做
flywindy
?
Integrating tornado and webpack
Integrating tornado and webpackIntegrating tornado and webpack
Integrating tornado and webpack
Tom Chen
?
那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子那些年,我用 Django Admin 接的案子
那些年,我用 Django Admin 接的案子
flywindy
?
Learning django step 1
Learning django step 1Learning django step 1
Learning django step 1
永昇 陳
?
Django workshop homework 3
Django workshop homework 3Django workshop homework 3
Django workshop homework 3
flywindy
?

Similar to Gitlab (20)

COSCUP 2015 開源之道-Git工作坊教學簡報
COSCUP 2015 開源之道-Git工作坊教學簡報COSCUP 2015 開源之道-Git工作坊教學簡報
COSCUP 2015 開源之道-Git工作坊教學簡報
Bachue Zhou
?
Learning to Use Git | WeiYuan
Learning to Use Git | WeiYuanLearning to Use Git | WeiYuan
Learning to Use Git | WeiYuan
Wei-Yuan Chang
?
CICD Workshop 20180922
CICD Workshop 20180922CICD Workshop 20180922
CICD Workshop 20180922
Earou Huang
?
Git 使用介绍
Git 使用介绍Git 使用介绍
Git 使用介绍
medcl
?
骋颈迟丑耻产介绍及实用入门
骋颈迟丑耻产介绍及实用入门骋颈迟丑耻产介绍及实用入门
骋颈迟丑耻产介绍及实用入门
Rongxing Liu
?
Git 入门实战
Git 入门实战Git 入门实战
Git 入门实战
icy leaf
?
骋颈迟基础培训
骋颈迟基础培训骋颈迟基础培训
骋颈迟基础培训
诸葛修车网-诸葛商城
?
為自己學 Git
為自己學 Git為自己學 Git
為自己學 Git
昀 李
?
FHIR Server 安裝與使用
FHIR Server 安裝與使用FHIR Server 安裝與使用
FHIR Server 安裝與使用
Lorex L. Yang
?
Visual Studio Code 快速上手指南
Visual Studio Code 快速上手指南Visual Studio Code 快速上手指南
Visual Studio Code 快速上手指南
Shengyou Fan
?
Learn git
Learn gitLearn git
Learn git
甘 李
?
Continuous Delivery with Ansible x GitLab CI (2e)
Continuous Delivery with Ansible x GitLab CI (2e)Continuous Delivery with Ansible x GitLab CI (2e)
Continuous Delivery with Ansible x GitLab CI (2e)
Chu-Siang Lai
?
Git&Github Tutorial
Git&Github TutorialGit&Github Tutorial
Git&Github Tutorial
Ting Wen Su
?
Cocoa on Rails 4th
Cocoa on Rails 4thCocoa on Rails 4th
Cocoa on Rails 4th
Xiaochun Shen
?
骋颈迟教学
骋颈迟教学骋颈迟教学
骋颈迟教学
Sitg Yao
?
大家應該都要會的工具 Git 從放棄到會用1-基礎篇
大家應該都要會的工具 Git   從放棄到會用1-基礎篇大家應該都要會的工具 Git   從放棄到會用1-基礎篇
大家應該都要會的工具 Git 從放棄到會用1-基礎篇
Alan Tsai
?
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer Talk
Larry Cai
?
Git & git flow
Git & git flowGit & git flow
Git & git flow
Amo Wu
?
Android 程式設計(4)
Android 程式設計(4)Android 程式設計(4)
Android 程式設計(4)
Roy Wang
?
Git Tutorial
Git TutorialGit Tutorial
Git Tutorial
Drake Huang
?
COSCUP 2015 開源之道-Git工作坊教學簡報
COSCUP 2015 開源之道-Git工作坊教學簡報COSCUP 2015 開源之道-Git工作坊教學簡報
COSCUP 2015 開源之道-Git工作坊教學簡報
Bachue Zhou
?
Learning to Use Git | WeiYuan
Learning to Use Git | WeiYuanLearning to Use Git | WeiYuan
Learning to Use Git | WeiYuan
Wei-Yuan Chang
?
CICD Workshop 20180922
CICD Workshop 20180922CICD Workshop 20180922
CICD Workshop 20180922
Earou Huang
?
Git 使用介绍
Git 使用介绍Git 使用介绍
Git 使用介绍
medcl
?
骋颈迟丑耻产介绍及实用入门
骋颈迟丑耻产介绍及实用入门骋颈迟丑耻产介绍及实用入门
骋颈迟丑耻产介绍及实用入门
Rongxing Liu
?
Git 入门实战
Git 入门实战Git 入门实战
Git 入门实战
icy leaf
?
為自己學 Git
為自己學 Git為自己學 Git
為自己學 Git
昀 李
?
FHIR Server 安裝與使用
FHIR Server 安裝與使用FHIR Server 安裝與使用
FHIR Server 安裝與使用
Lorex L. Yang
?
Visual Studio Code 快速上手指南
Visual Studio Code 快速上手指南Visual Studio Code 快速上手指南
Visual Studio Code 快速上手指南
Shengyou Fan
?
Continuous Delivery with Ansible x GitLab CI (2e)
Continuous Delivery with Ansible x GitLab CI (2e)Continuous Delivery with Ansible x GitLab CI (2e)
Continuous Delivery with Ansible x GitLab CI (2e)
Chu-Siang Lai
?
Git&Github Tutorial
Git&Github TutorialGit&Github Tutorial
Git&Github Tutorial
Ting Wen Su
?
骋颈迟教学
骋颈迟教学骋颈迟教学
骋颈迟教学
Sitg Yao
?
大家應該都要會的工具 Git 從放棄到會用1-基礎篇
大家應該都要會的工具 Git   從放棄到會用1-基礎篇大家應該都要會的工具 Git   從放棄到會用1-基礎篇
大家應該都要會的工具 Git 從放棄到會用1-基礎篇
Alan Tsai
?
Software Engineer Talk
Software Engineer TalkSoftware Engineer Talk
Software Engineer Talk
Larry Cai
?
Git & git flow
Git & git flowGit & git flow
Git & git flow
Amo Wu
?
Android 程式設計(4)
Android 程式設計(4)Android 程式設計(4)
Android 程式設計(4)
Roy Wang
?

Gitlab