Skip to content

Commit 5e17f61

Browse files
committed
update git tutorial
1 parent 755b7e2 commit 5e17f61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2110
-0
lines changed

git/.gitignore

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
_book/
61+

git/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Ai-Lin Liou
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

git/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Introduction
2+
3+
### 講師
4+
5+
劉艾霖
6+
7+
> 實務上的 Web Full Stack 開發經驗,熟悉 Java 以及 JavaScript 開發技術,專精於網站開發、架構設計與撰寫前後端自動化測試。是位全端工程師、後端工程師、測試開發工程師、企業內訓講師,具有 8 年軟體開發相關資歷,目前從事企業技術教學、技術顧問、軟體開發。
8+
9+
> 培訓經驗:曾於 JSDC 2016、Modern Web 2016、Testing Day 2017 等技術大會擔任講者,並於各大院校、資策會、IThome、企業內訓等機構擔任技術研獎及 Workshop 講者。
10+
11+
### 上課注意事項
12+
13+
#### 需事前安裝以下軟體
14+
15+
* 如果你還沒有 GitHub 帳號,請在 [GitHub 官方網站](https://github.com/)進行註冊。
16+
* 建議使用 Google Chrome 瀏覽器
17+
* VirtualBox 5.x 以上版本虛擬機器軟體及 Extension Pack
18+
19+
#### 並確保電腦規格符合以下建議條件:
20+
21+
1. 建議使用 64 位元作業系統
22+
1. 作業系統 Windows、Mac 或 Linux 皆可
23+
1. 建議 8GB 以上實體記憶體(最低需求為 4GB)
24+
1. 至少 40GB 磁碟可用空間
25+
26+
我們在課程中會提供實作練習專用的 VM Image,以方便搭配教材內容。
27+
28+
## License
29+
30+
MIT © [alincode](https://github.com/alincode)

git/SUMMARY.md

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Summary
2+
3+
* [Introduction](README.md)
4+
* [確認環境](prepare/vm.md)
5+
* [Git 基礎]()
6+
* [Git 是什麼?](foundation/what.md)
7+
* [為什麼我們需要 Git](foundation/why.md)
8+
* [Git vs SVN](foundation/git-vs-svn.md)
9+
* [初始化專案 init](command/init.md)
10+
* [設定檔](command/config.md)
11+
* [練習題:建立一個裸容器](practice/init.md)
12+
* [觀念講解:索引](foundation/index.md)
13+
* [觀念講解:認識 Git 物件](foundation/object.md)
14+
* [Git 之 CRUD]()
15+
* [工作區、暫存區、儲存庫](foundation/space.md)
16+
* [狀態 status](command/status.md)
17+
* [新增 add](command/add.md)
18+
* [送交 commit](command/commit.md)
19+
* [練習題:新增一個送交紀錄](practice/commit.md)
20+
* [檢視 log / show](command/log.md)
21+
* [比對差異 diff](command/diff.md)
22+
* [刪除 rm](command/rm.md)
23+
* [練習題:刪除檔案](practice/rm.md)
24+
* [重新命名 mv](command/mv.md)
25+
* [觀念講解: Git Flow]()
26+
* [整體概念](git-flow/README.md)
27+
* [master 分支](git-flow/master.md)
28+
* [feature 分支](git-flow/feature.md)
29+
* [hotfix 分支](git-flow/hotfix.md)
30+
* [分支 branch]()
31+
* [分支 branch CRUD](command/branch.md)
32+
* [切換 checkout](command/checkout.md)
33+
* [練習題:新增一個分支](practice/branch.md)
34+
* [合併 merge](command/merge.md)
35+
* [觀念解說:解決衝突](foundation/conflict.md)
36+
* [練習題:解決衝突](practice/conflict.md)
37+
* [暫存 stash](command/stash.md)
38+
* [練習題:將檔案放入暫存區](practice/stash.md)
39+
* [修改送交]()
40+
* [還原 reset](command/reset.md)
41+
* [資料還原 revert](command/revert.md)
42+
* [(進階指令) rebase](command/rebase.md)
43+
* [觀念講解:reset vs revert](foundation/reset-vs-revert.md)
44+
* [練習題:還原狀態](practice/reset.md)
45+
* [遠端協作]()
46+
* [容器](foundation/container.md)
47+
* [remote](command/remote.md)
48+
* [複製 clone](command/clone.md)
49+
* [拉 pull](command/pull.md)
50+
* [更新 fetch](command/fetch.md)
51+
* [練習題:透過 fetch 指令取得最新送交紀錄](practice/fetch.md)
52+
* [部署 push](command/push.md)
53+
* [練習題:發佈送交](practice/push.md)
54+
* [標籤 tag](command/tag.md)
55+
* [練習題:發佈 tag](practice/tag.md)
56+
* [Github](github/README.md)
57+
* [issue](github/issue.md)
58+
* [clone](github/clone.md)
59+
* [fork](github/fork.md)
60+
* [pull request](github/pr.md)
61+
* [練習題:操作 Github](practice/github.md)
62+
* [補充]()
63+
* [blame](command/blame.md)
64+
* [grep](command/grep.md)
65+
* [tig](mise/tig.md)
66+
* [實用小技巧](tips.md)
67+
* [更多資源](resource.md)
68+
69+
70+
<!--
71+
72+
* [正確的提交習慣與工作流程](foundation/commit-flow.md)
73+
74+
* [(進階)cherry pick](command/cherry-pick.md)
75+
76+
77+
* [bisect](command/bisect.md)
78+
* [reflog](command/reflog.md)
79+
* [submodule](command/submodule.md)
80+
81+
* [ph-page]()
82+
* [standup](mise/standup.md)
83+
-->

git/command/add.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# git add 指令
2+
3+
將檔案放入索引。將檔案備份到「物件儲存」中,使用 SHA1 算出名稱並且建立索引,將檔案放入準備狀態。
4+
### 常用範例
5+
6+
| 範例 | 說明 |
7+
|--------------------|-----|
8+
| git add README.txt | |
9+
| git add . | 將資料先暫存到 staging area |
10+
11+
### 語法結構
12+
13+
```
14+
usage: git add [<options>] [--] <pathspec>...
15+
16+
-n, --dry-run dry run
17+
-v, --verbose be verbose
18+
19+
-i, --interactive interactive picking
20+
-p, --patch select hunks interactively
21+
-e, --edit edit current diff and apply
22+
-f, --force allow adding otherwise ignored files
23+
-u, --update update tracked files
24+
-N, --intent-to-add record only the fact that the path will be added later
25+
-A, --all add changes from all tracked and untracked files
26+
--ignore-removal ignore paths removed in the working tree (same as --no-all)
27+
--refresh don't add, only refresh the index
28+
--ignore-errors just skip files which cannot be added because of errors
29+
--ignore-missing check if - even missing - files are ignored in dry run
30+
```
44.2 KB
Loading

git/command/assets/fast-forward.png

130 KB
Loading

git/command/assets/noff.png

142 KB
Loading

git/command/assets/status.png

45.6 KB
Loading

git/command/assets/status2.png

78.6 KB
Loading

git/command/bisect.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Git Bisect 指令
2+
3+
```
4+
git bisect start
5+
git bisect bad
6+
git bisect good
7+
git bisect log
8+
git bisect replay
9+
git visuallize --pretty-oneline
10+
git bisect reset
11+
```

git/command/blame.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# git blame 指令
2+
3+
### 使用情境
4+
5+
* 追蹤 bug,查看這行程式誰的。
6+
7+
### 常用範例
8+
9+
| 範例 | 說明 |
10+
|----------------------------|--------|
11+
| git blame -L 2,5 hello.txt | |
12+
| git blame -L 2 hello.txt | |
13+
| git blame -L 2, hello.txt | |
14+
| git blame -L ,5 hello.txt | 追蹤修改紀錄 |
15+
16+
### 語法結構
17+
18+
```
19+
usage: git blame [<options>] [<rev-opts>] [<rev>] [--] <file>
20+
21+
<rev-opts> are documented in git-rev-list(1)
22+
23+
--incremental Show blame entries as we find them, incrementally
24+
-b Show blank SHA-1 for boundary commits (Default: off)
25+
--root Do not treat root commits as boundaries (Default: off)
26+
--show-stats Show work cost statistics
27+
--score-debug Show output score for blame entries
28+
-f, --show-name Show original filename (Default: auto)
29+
-n, --show-number Show original linenumber (Default: off)
30+
-p, --porcelain Show in a format designed for machine consumption
31+
--line-porcelain Show porcelain format with per-line commit information
32+
-c Use the same output mode as git-annotate (Default: off)
33+
-t Show raw timestamp (Default: off)
34+
-l Show long commit SHA1 (Default: off)
35+
-s Suppress author name and timestamp (Default: off)
36+
-e, --show-email Show author email instead of name (Default: off)
37+
-w Ignore whitespace differences
38+
--minimal Spend extra cycles to find better match
39+
-S <file> Use revisions from <file> instead of calling git-rev-list
40+
--contents <file> Use <file>'s contents as the final image
41+
-C[<score>] Find line copies within and across files
42+
-M[<score>] Find line movements within and across files
43+
-L <n,m> Process only line range n,m, counting from 1
44+
--abbrev[=<n>] use <n> digits to display SHA-1s
45+
```

git/command/branch.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# git branch CRUD
2+
3+
git branch --all ```
4+
* master
5+
remotes/origin/HEAD -> origin/master
6+
remotes/origin/master
7+
```
8+
9+
### 名稱
10+
11+
* 絕對名稱
12+
* 參照名稱
13+
14+
```
15+
refs/head
16+
refs/remotes
17+
refs/tags
18+
```
19+
20+
### 常用範例
21+
22+
| 範例 | 說明 |
23+
|------------------------|---------------------------|
24+
| git branch dev | 新增 dev 分支 |
25+
| git branch | 列出 local 分支 |
26+
| git branch -r | 列出遠端分支 |
27+
| git branch -a | 列出所有分支 |
28+
| git branch -m dev dev2 | 修改分支名稱 |
29+
| git branch -d dev2 | 刪除分支 |
30+
| git branch -D dev2 | 強迫刪除分支 (即使分支,還沒被 merge 過) |
31+
32+
### 相關聯指令
33+
34+
| 範例 | 說明 |
35+
|---------------------|-----------|
36+
| git push origin dev | 發佈 dev 分支 |
37+
38+
### 語法結構
39+
40+
```
41+
usage: git branch [<options>] [-r | -a] [--merged | --no-merged]
42+
or: git branch [<options>] [-l] [-f] <branch-name> [<start-point>]
43+
or: git branch [<options>] [-r] (-d | -D) <branch-name>...
44+
or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>
45+
or: git branch [<options>] [-r | -a] [--points-at]
46+
```

git/command/checkout.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# git checkout 指令
2+
3+
checkout 可用於將特定版本檔案取出,無論是資料夾或檔案皆可。
4+
5+
### 使用情境
6+
7+
* 切換分支
8+
* 發現檔案改錯,用git checkout filename把檔案還原到最新的版本
9+
### 常用指令範例
10+
11+
| 範例 | 說明 |
12+
|--------------------------|-------------------------------|
13+
| git checkout README.md | 取出 README.md 檔案 |
14+
| git checkout docs/ | 取出特 docs 資料夾 |
15+
| git checkout dev | 取出 dev 分支 |
16+
| git checkout -b dev | 新增 dev 分支,並同時切換到 dev 分之上 |
17+
| git checkout — README.md | 將 README.md 恢復到上一次 Commit 的狀態 |
18+
19+
### 語法結構
20+
21+
```
22+
usage: git checkout [<options>] <branch>
23+
or: git checkout [<options>] [<branch>] -- <file>...
24+
25+
-q, --quiet suppress progress reporting
26+
-b <branch> create and checkout a new branch
27+
-B <branch> create/reset and checkout a branch
28+
-l create reflog for new branch
29+
--detach detach the HEAD at named commit
30+
-t, --track set upstream info for new branch
31+
--orphan <new-branch>
32+
new unparented branch
33+
-2, --ours checkout our version for unmerged files
34+
-3, --theirs checkout their version for unmerged files
35+
-f, --force force checkout (throw away local modifications)
36+
-m, --merge perform a 3-way merge with the new branch
37+
--overwrite-ignore update ignored files (default)
38+
--conflict <style> conflict style (merge or diff3)
39+
-p, --patch select hunks interactively
40+
--ignore-skip-worktree-bits
41+
do not limit pathspecs to sparse entries only
42+
--ignore-other-worktrees
43+
do not check if another worktree is holding the given ref
44+
--progress force progress reporting
45+
```

git/command/cherry-pick.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# git cherry-pick 指令
2+
3+
### 使用情境
4+
5+
* 把弄錯分支的提交移到正確的地方
6+
* 將其他分支的提交也添加到現在的分支

0 commit comments

Comments
 (0)