Top Banner
git Yeast Liu 2014.04.01 @ NISRA
58

Git

May 06, 2015

Download

Education

Yeast Liu

NISRA 2014.04.01
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Git

git

Yeast Liu2014.04.01 @ NISRA

Page 2: Git

Outline

• About Version Control• Hello, Git! • Git GUI• Git Branching

Page 3: Git

Outline

• About Version Control• What is “Version Control” ?• Version Control Systems• Local Version Control Systems• Centralized Version Control Systems• Distributed Version Control Systems

• Hello, Git!• Git GUI• Git Branching

Page 4: Git

About Version Control• What is version control ?

• Local Version Control Systems• 在 local 各自建立版本資料庫• 協作開發困難

• Centralized Version Control Systems• 利用一台中央 Server 儲存所有版本紀錄• SVN ( Subversion )• Server 負擔大

• Distributed Version Control Systems• 每個 local 都有一個版本資料庫• git

Page 5: Git

Local Version Control Systems

commit

Page 6: Git

Centralized Version Control Systems

commit

Page 7: Git

Distributed Version Control Systems

commit

push/pull

Page 8: Git

Outline

• About Version Control• Hello, Git! • What is Git?• Getting Started• Git Basics• Git and Github

• Git GUI• Git Branching

Page 9: Git

What is Git?

• A distributed version control system.• Designed and developed by Linus Torvalds.• A distributed revision control and source code

management system.

Page 10: Git

What is Git? – Other VCS

• Store data as changes.

Page 11: Git

What is Git? – Git VCS

• DAG ( Directed Acyclic Graph): Store data as snapshots.

Page 12: Git

Outline

• About Version Control• Hello, Git!• What is Git?• Getting Started• Installing Git• First-Time Git Setup• Get Help

• Git Basics• Git and Github

• Git GUI• Git Branching

Page 13: Git

Getting Started : Installing Git

• Install git on Windows

• Install git on Ubuntu

$ sudo apt-get install git

http://msysgit.github.io/

Page 14: Git

Getting Started : Git Setup

$ git config --global user.name “Your Name”

• First-Time git setup

$ git config --global user.email “Your Email”

Page 15: Git

Getting Started : Git Setup

$ cat ~/.gitconfig or $ vim ~/.gitconfig or

$ git config –list

• Check your git configuration.• ~/.gitconfig • 是隱藏在 home folder 中的設定檔

Page 16: Git

Getting Started : Getting Help

$ git help <command> or$ git <command> --help

• Get the manual page for help.

$ git help config

Page 17: Git

Outline

• About Version Control• Hello, Git!• What is Git?• Getting Started• Git Basics• Git Repository• Commands

• Git and Github• Git GUI• Git Branching

Page 18: Git

Getting Basics : Git Repository (Repo)

• Repositories

• 一個儲存專案中所有修訂資訊、歷史紀錄的資料庫• .git 是一個隱藏目錄 , 存放 Repo 所需要的資訊 .

Page 19: Git

Getting Basics : Git Repository (Repo)

Page 20: Git

Git Basics : Git Repository (Repo)

• Git Repo : 一個被 Git 追蹤的專案• Repo stored the collection of files and their

complete history.

Page 21: Git

Git Basics : Git Repository (Repo)

3

3

Page 22: Git

Outline• About Version Control• Hello, Git!• What is Git?• Getting Started• Git Basics• Git Repository• Commands

• Git and Github• Git GUI• Git Branching

Page 23: Git

Git Basics : Commands

• Create a empty directory.

• Create git repository.

$ mkdir hellogit$ cd hellogit

$ git init

Page 24: Git

Git Basics : Commands

• Create content

• Show content

$ touch data.txt$ echo “content” > data.txt$ echo “concat” >> data.txt

$ cat data.txt

Page 25: Git

Git Basics : Commands

• See the current status.

$ git status

Page 26: Git

Git Basics : Commands

• Add file to the staging area.

$ git add data.txt$ git add .

Page 27: Git

Git Basics : Commands

• Remove file to the staging area. $ git rm data.txt

Page 28: Git

Git Basics : Commands

• Commit file to the local repository.

$ git commit –m “Your commit msg”

Page 29: Git

Git Basics : Commands

• Show git log for the change.

$ git log

Page 30: Git

Outline

• About Version Control• Hello, Git!• What is Git?• Getting Started• Git Basics• Git and Github

• Git GUI• Git Branching

Page 31: Git
Page 32: Git

• Make a new repository on GitHub.

Github : Git and Github

Page 33: Git

• Make a new repository on GitHub.

Github : Git and Github

“Your Repo Name”

Page 34: Git

• Creates a remote named “origin” pointing at your github repo.

Github : Git and Github

$ git remote add origin “URL”

“ URL ”

Page 35: Git

• Push your commit.

Github : Git and Github

$ git push origin master

Page 36: Git

• Push your commit.

Github : Git and Github

$ git push origin master

Page 37: Git

• Push your commit.

Github : Git and Github

Page 38: Git

Outline

• About Version Control• Hello, Git!• Git GUI• Git Branching

Page 39: Git

Git GUI

• Graphical Git Client for Linux• Git-cola• Gitg• SmartGit• Giggle• Git Gui• qGit• gitk

Page 40: Git

Git GUI

• Gitk

Page 41: Git

Outline

• About Version Control• Hello, Git!• Git GUI• Git Branching• Data Structures• About Branching• Merge Branches

Page 42: Git

Git Branching : Data Structures

紀錄檔案內容

檔案目錄紀錄訊息

Page 43: Git

Git Branching : Data Structures

• Single commit repository data.

Page 44: Git

Git Branching : Data Structures

• Git object data for multiple commits.

Page 45: Git

Outline

• About Version Control• Hello, Git!• Git GUI• Git Branching• Data Structures• About Branching• Merge Branches

Page 46: Git

Git Branching: About Branching

• Create a new branch.

$ git branch testing “ Your branch name”

Page 47: Git

Git Branching: About Branching

• Switch to an existing branch.

$ git checkout testing “ Your branch name”

Page 48: Git

Git Branching: About Branching

• Switch to an existing branch.

$ git checkout testing “ Your branch name”

Page 49: Git

Outline

• About Version Control• Hello, Git!• Git GUI• Git Branching• Data Structures• About Branching• Merge Branches

Page 50: Git

Git Branching: Merge Branches

$ git checkout –b iss53 “ Your branch name”

Page 51: Git

Git Branching: Merge Branches

index.html

$ vim index.html$ git add

$ git commit –m “issue 53”

Page 52: Git

index.html

index.html

$ git checkout master$ git checkout –b hotfix

$ vim index.html$ vim add

$ git commit –m “hotfix”

Page 53: Git

index.html

index.html

$ git checkout master$ git merge hotfix

$ git branch –d hotfix

Page 54: Git

$ git checkout master$ git merge iss53

Page 55: Git

master and iss53 : no common ancestors

Page 56: Git

master and iss53 : no common ancestors

Page 57: Git

Reference

• Git Documentation• http://git-scm.com/documentation

• 版本控制系統 Git  精要 | ihower 的 Git  教室• http://ihower.tw/git/remote.html

• 寫給大家的 Git  教學• http://www.slideshare.net/littlebtc/git-5528339

Page 58: Git

Q & A 愚人節快樂 :)