Git Version Control Hello MIS 2 A 104403521

  • Slides: 42
Download presentation
Git Version Control

Git Version Control

Hello! � 簡報提供:MIS 2 A 104403521 You can find me at: evan 11401@gmail. com

Hello! � 簡報提供:MIS 2 A 104403521 You can find me at: evan 11401@gmail. com 2

0. What is Version control 先從以下幾張照片說起 3

0. What is Version control 先從以下幾張照片說起 3

1. GIT Basic concept 9

1. GIT Basic concept 9

add Working 放在資料夾中的檔案 Directory ls com mit Staging 暫存你想存檔的檔案 AREA REPOSITO Git的版本控制資料庫 RY git

add Working 放在資料夾中的檔案 Directory ls com mit Staging 暫存你想存檔的檔案 AREA REPOSITO Git的版本控制資料庫 RY git status git log 10

檔案的狀態 Working Directory untracked modified Staging AREA REPOSITO RY staged umodified 13

檔案的狀態 Working Directory untracked modified Staging AREA REPOSITO RY staged umodified 13

File status $ Untracked files // 全新的檔案, git會當他不存在 $ Changes not staged for commit

File status $ Untracked files // 全新的檔案, git會當他不存在 $ Changes not staged for commit // 被修改過的檔案 $ Changes to be committed // From staging area to working directory 14

File Move And Rename $ git mv <file> <directory> // 把檔案移到某個資料夾底下 $ git mv

File Move And Rename $ git mv <file> <directory> // 把檔案移到某個資料夾底下 $ git mv <file> <new_name> // 把檔案重新命名 $操作完會自動在Staging AREA中 // Status changes to be committed 15

Commit Edit $ git commit --amend -m <title> // 修改上一個commit, 只改title就使用-m $$$更改過任何檔案後請別用 17

Commit Edit $ git commit --amend -m <title> // 修改上一個commit, 只改title就使用-m $$$更改過任何檔案後請別用 17

2. GIT BRANCh 18

2. GIT BRANCh 18

3 -1. GIT merge 21

3 -1. GIT merge 21

3 -2. GIT REBASE 24

3 -2. GIT REBASE 24

REBASE==一堆Cherry-Pick $ git rebase master <branch> //把指定的branch合併到master上 $ git checkout <branch> $ git rebase

REBASE==一堆Cherry-Pick $ git rebase master <branch> //把指定的branch合併到master上 $ git checkout <branch> $ git rebase master //與上面等價 25

4. Resolving a merge conflict 27

4. Resolving a merge conflict 27

5. GIT REmote repository 30

5. GIT REmote repository 30

Working Directory Staging AREA REPOSI TORY remote REPOSITO RY Working Directory Staging AREA REPOSI

Working Directory Staging AREA REPOSI TORY remote REPOSITO RY Working Directory Staging AREA REPOSI TORY 31

連結遠端REPO $ git remote add origin git@HOSTPATH: REPO_NAME // 設定你的本地 repo 跟遠端連結 複製遠端REPO $

連結遠端REPO $ git remote add origin git@HOSTPATH: REPO_NAME // 設定你的本地 repo 跟遠端連結 複製遠端REPO $ git clone git@HOSTPATH: REPO_NAME // 複製遠端的repo到本機,會在當前目錄下建立同名的新資料夾 關於 git@HOSTPATH 與 https: //HOSTPATH 的差別? help. github. com/articles/which-remote-url-should-i-use/ 33

remote & local ‘s communication git push Local repo git pull /FETCH remote repo

remote & local ‘s communication git push Local repo git pull /FETCH remote repo NOTE: git pull = git fetch + git merge FETCH_HEAD 35

5. BECOMing git master 36

5. BECOMing git master 36

其他進階指令 ✖git stash https: //goo. gl/RZ 2 n. H 1 ✖git rebase https: //goo.

其他進階指令 ✖git stash https: //goo. gl/RZ 2 n. H 1 ✖git rebase https: //goo. gl/fzx. Oy. P ✖git revert https: //goo. gl/ju. PIOL ✖git cherry-pick https: //goo. gl/Z 9 Ibs. N 37

實作! ✖ 1. 安裝git ✖ 2. 輸入下列 git config --global user. email "you@example. com"

實作! ✖ 1. 安裝git ✖ 2. 輸入下列 git config --global user. email "you@example. com" git config --global user. name "Your Name" git config --global color. ui true 38

39

39

HOMEWORK 40

HOMEWORK 40

任務清單 ✖Try Github online https: //try. github. io/ ✖Git 起步走 https: //git-scm. com/book/zh-tw/v 1

任務清單 ✖Try Github online https: //try. github. io/ ✖Git 起步走 https: //git-scm. com/book/zh-tw/v 1 ✖動手玩玩看 41

Thanks! Any questions? You can find me at: evan 11401@gmail. com 42

Thanks! Any questions? You can find me at: evan 11401@gmail. com 42