From 4f2553ba821b9dd7463dd7c491bac6e8954ce655 Mon Sep 17 00:00:00 2001 From: subineru Date: Sat, 7 May 2022 11:40:47 +0800 Subject: [PATCH] day37(zh-tw) in progress --- zh_tw/Days/day37.md | 64 ++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/zh_tw/Days/day37.md b/zh_tw/Days/day37.md index 4913e2e..8e71301 100644 --- a/zh_tw/Days/day37.md +++ b/zh_tw/Days/day37.md @@ -11,7 +11,7 @@ id: 1048707 本篇的作者在這裡玩了個諧音梗,把英文的 Getting to know Git 改寫成 Gitting to know Git。 -在前兩篇文章中我們學習了有關版本控制,[第35天](day35.md)講到 Git 做為一個版本控制系統有哪些基本的工作流程。[第36天](day36.md)講到如何安裝、更新和設定,更稍微深入探討主從式和分佈式版本控制系統 Git 之間的理論。 +在前兩篇文章中我們學習了有關版本控制,[第35天](day35.md)講到 Git 做為一個版本控制系統具有哪些基本的工作流程。[第36天](day36.md)講到如何安裝、更新和設定,更稍稍地深入探討主從式和分佈式版本控制系統 Git 之間的理論。 現在,我們將迅速帶過在 Git 常見的指令和使用案例。 @@ -19,29 +19,29 @@ id: 1048707 有時候你會忘記或是不曉得要用什麼 Git 指令來達到你要的需求。這時候你會需要幫助。 -不用說通常大家都會優先用Google和任何的搜尋引擎來尋找你要的答案。 +不用說通常大家都會優先用 Google 或任何的搜尋引擎尋找你要的答案。 -第二種方法是你也可以到 Git 官方網站取得文件說明。 [git-scm.com/docs](http://git-scm.com/docs) 鏈結不僅可以找到所有命令的參考資訊,還能找到不同的資源(如下圖)。 +第二種方法是你也能到 Git 官方網站取得文件說明。 [git-scm.com/docs](http://git-scm.com/docs) 連結裡不僅可以找到所有命令的參考資訊,還能找到不同的資源(如下圖)。 ![](Images/Day37_Git1.png) -從終端機上也可以找到跟 Git 官方網站相同的說明。如果我們要用指令`git add`,但是不確定使用方式時就能夠輸入`git add --help`來取得說明。 +從終端機上也有跟 Git 官方網站相同的說明。如果我們要用指令`git add`,但是不確定使用方式時就能夠輸入`git add --help`來取得說明。 ![](Images/Day37_Git2.png) -我們也可以輸入指令`git add -h`來取得較簡短的說明。 +我們也可以輸入指令`git add -h`來取得簡潔的說明。 ![](Images/Day37_Git3.png) ### 圍繞在 Git 的神話 -"Git 沒有授權控制" - 所以你可以授權領導者維護原始碼。 +"Git 沒有存取控制功能" - 但你可以授權一名領導者維護原始碼。 "Git 太肥" - 如果你有大型的專案,Git 有能力提供淺層儲存庫,基本上這意味著它能夠減少歷史的紀錄。 ### 真正的缺點 -不適合用在二進位檔案。Git 適合用在原始碼,但如果是執行檔或影片就不建議。 +不適合用在二進位檔案。Git 適合用在原始碼,如果是執行檔或影片就不建議。 Git 對使用的人並不友善,事實上我們必須花費時間討論命令和功能怎麼使用。 @@ -81,29 +81,29 @@ Git 對使用的人並不友善,事實上我們必須花費時間討論命令 ### Git Undoing Changes -| 指令 | 範例 | 描述 | -| ------------ | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -| git revert | `git revert ` | 做反向處理,回復這次提交的異動,並建立新的提供。 | -| git reset | `git reset ` | Remove from the staging area, but leave the working directory unchanged. This unstages a file without overwriting any changes. | -| git clean | `git clean -n` | 列出那些檔案會從你的工作目錄刪除。`-n`改成`-f`就會真正執行刪除。 | +| 指令 | 範例 | 描述 | +| ------------ | ----------------------- | ------------------------------------------------------------------------------------------- | +| git revert | `git revert ` | 進行反向處理,回復該次提交的異動,並建立新的提交。 | +| git reset | `git reset ` | 還原暫存區到最近提交的版本,但是不變動工作目錄的檔案。 這將會取消暫存文件而不做任何覆蓋。 | +| git clean | `git clean -n` | 列出那些檔案會從你的工作目錄刪除。`-n`改成`-f`就會真正執行刪除。 | ### Git Rewriting History -| 指令 | 範例 | 描述 | -| ------------ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -| git commit | `git commit --amend` | Replace the last commit with the staged changes and last commit combined. Use with nothing staged to edit the last commit’s message. | -| git rebase | `git rebase ` | Rebase the current branch onto. can be a commit ID, branch name, a tag, or a relative reference to HEAD. | -| git reflog | `git reflog` | Show a log of changes to the local repository’s HEAD. Add --relative-date flag to show date info or --all to show all refs. | +| 指令 | 範例 | 描述 | +| ------------ | ---------------------- | ------------------------------------------------------------------------------------------------------------------- | +| git commit | `git commit --amend` | 將變更過的暫存區和最後的提交合併後取代最後一次的提交。 如果暫存區沒有變更就可以修改註解。 | +| git rebase | `git rebase ` | 重新定義現在的分支,將其它分支當作現在分支的基礎,目標可以是一個 ID、分支名稱、一個標籤或一個 HEAD 的相對參考點。 | +| git reflog | `git reflog` | 顯示本機儲存庫HEAD變動的歷史紀錄。加配置選項 --relative-date 可以顯示日期,加 --all 顯示所有的參照. | ### Git Branches -| 指令 | 範例 | 描述 | -| -------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------- | -| git branch | `git branch` | List all of the branches in your repo. Add a argument to create a new branch with the name . | -| git checkout | `git checkout -b ` | Create and check out a new branch named. Drop the -b flag to checkout an existing branch. | -| git merge | `git merge ` | Merge into the current branch. | +| 指令 | 範例 | 描述 | +| -------------- | ---------------------------- | --------------------------------------------------------------- | +| git branch | `git branch` | 列出儲存庫上所有的分支。再加一個變數名字則可以建立新分支。 | +| git checkout | `git checkout -b ` | 創建一個新的分支。 移除參數 -b 則用來切換一支已經存在的分支。 | +| git merge | `git merge ` | 合併到現在的分支。 | ### Git Remote Repositories @@ -118,10 +118,10 @@ Git 對使用的人並不友善,事實上我們必須花費時間討論命令 ### Git Diff -| 指令 | 範例 | 描述 | -| ------------------- | --------------------- | ------------------------------------------------------------ | -| git diff HEAD | `git diff HEAD` | Show difference between working directory and last commit. | -| git diff --cached | `git diff --cached` | Show difference between staged changes and last commit | +| 指令 | 範例 | 描述 | +| ------------------- | --------------------- | ---------------------------------------- | +| git diff HEAD | `git diff HEAD` | 比對最新的提交和工作目錄內的檔案內容。 | +| git diff --cached | `git diff --cached` | 比對最新的提交和索引內的檔案內容。 | ### Git Config @@ -151,12 +151,12 @@ Git 對使用的人並不友善,事實上我們必須花費時間討論命令 ### Git Reset -| 指令 | 範例 | 描述 | -| -------------------------- | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| git reset | `git reset ` | Reset staging area to match most recent commit, but leave the working directory unchanged. | -| git reset --hard | `git reset --hard` | Reset staging area and working directory to match most recent commit and overwrites all changes in the working directory | -| git reset | `git reset ` | Move the current branch tip backward to, reset the staging area to match, but leave the working directory alone | -| git reset --hard | `git reset --hard ` | Same as previous, but resets both the staging area & working directory to match. Deletes uncommitted changes, and all commits after. | +| 指令 | 範例 | 描述 | +| -------------------------- | ----------------------------- | -------------------------------------------------------------------------- | +| git reset | `git reset ` | 還原暫存區到最近提交的版本,但是不變動工作目錄的檔案。 | +| git reset --hard | `git reset --hard` | 還原暫存區和工作目錄到最新提交的版本,即使工作目錄有變更也會還原。 | +| git reset | `git reset ` | 還原暫存區到指定的版本,但是不變動工作目錄的檔案。 | +| git reset --hard | `git reset --hard ` | 還原暫存區和工作目錄到指定的版本。刪除未提交的更改,以及之後的所有提交。 | ### Git Push