day37(zh-tw) in-progress

This commit is contained in:
subineru 2022-05-06 23:26:55 +08:00
parent c698e367fa
commit 4f645663a2
2 changed files with 52 additions and 52 deletions

View File

@ -17,7 +17,7 @@ To be successful in DevOps you have to have a good knowledge of programming skil
## Understand why you need to learn a programming language.
The reason that Python and Go are recommended so often for DevOps engineers is that a lot of the DevOps tooling is written in either Python or Go, which makes sense if you are going be build DevOps tools. Now this is important as this will determine really what you should learn and that would likely be the most beneficial. If you are going to be building DevOps tools or you are joining a team that does then it would make sense to learn that same language, if you are going to be heavily involved in Kubernetes or Containers then it's more than likely that you would want to choose Go as your programming language. For me, the company I work for (Kasten by Veeam) is in the Cloud-Native ecosystem focused on data management for Kubernetes and everything is written in Go.
The reason that Python and Go are recommended so often for DevOps engineers is that a lot of the DevOps tooling is written in either Python or Go, which makes sense if you are going to be building DevOps tools. Now this is important as this will determine really what you should learn and that would likely be the most beneficial. If you are going to be building DevOps tools or you are joining a team that does then it would make sense to learn that same language, if you are going to be heavily involved in Kubernetes or Containers then it's more than likely that you would want to choose Go as your programming language. For me, the company I work for (Kasten by Veeam) is in the Cloud-Native ecosystem focused on data management for Kubernetes and everything is written in Go.
But then you might not have clear cut reasoning like that to choose you might be a student or transitioning careers with no real decision made for you. I think in this situation then you should choose the one that seems to resonate and fit with the applications you are looking to work with.

View File

@ -9,88 +9,88 @@ id: 1048707
---
## Git 入門
本篇的作者在這裡很有趣玩諧音梗,把英文的 Getting to know Git改寫成 Gitting to know Git。
本篇的作者在這裡很有趣玩諧音梗,把英文的 Getting to know Git 改寫成 Gitting to know Git。
在前兩篇文章中我們學習了有關版本控制,[第35天](day35.md) and some of the fundamental workflows of git as a version control system [ Then we got git installed on our system, updated and configured. We also went a little deeper on the theory between Client-Server version control system and Git which is a distributed version control system [Day 36](day36.md).
在前兩篇文章中我們學習了有關版本控制,[第35天](day35.md)講到了Git做為一個版本控制系統有哪些基本的工作流程。[第36天](day36.md)講到如何安裝、更新和設定,更稍微深入探討主從式和分佈式版本控制系統 Git 之間的理論。
Now we are going to run through some of the commands and use cases that we will all commonly see with git.
現在,我們將迅速帶過在 Git 常見的指令和使用案例。
### Where to git help with git?
### 何處取得Git文件?
There is going to be times where you just cannot remember or just don't know the command you need to get things done with git. You are going to need help.
有時候你會忘記或是不曉得要用什麼 Git 指令來達到你要的需求。這時候你會需要幫助。
It goes without saying that google or any search engine is likely to be your first port of call when searching help.
不用說通常大家都會優先用Google和任何的搜尋引擎來尋找你要的答案。
Secondly the next place is going to be the official git site and the documentation. [git-scm.com/docs](http://git-scm.com/docs) Here you will find not only a solid reference to all the commands available but also lots of different resources.
第二種方法是你也可以到 Git 官方網站取得文件說明。 [git-scm.com/docs](http://git-scm.com/docs) 鏈結不僅可以找到所有命令的參考資訊,還能找到不同的資源(如下圖)。
![](Images/Day37_Git1.png)
We can also access this same documentation which is super useful if you are without connectivity from the terminal. If we chose the `git add` command for example we can run `git add --help` and we see below the manual.
從終端機上也可以找到跟 Git 官方網站相同的說明。如果我們要用指令`git add`,但是不確定使用方式時就能夠輸入`git add --help`來取得說明。
![](Images/Day37_Git2.png)
We can also in the shell use `git add -h` which is going to give us a short summary of the options we have available.
我們也可以輸入指令`git add -h`來取得較簡短的說明。
![](Images/Day37_Git3.png)
### 圍繞在 Git 的神話
"Git has no access control" - You can empower a leader to maintain source code.
"Git 沒有授權控制" - 所以你可以授權領導者維護原始碼。
"Git 太肥 - Git has the ability to provide shallow repositories which basically means a reduced amount of history if you have large projects.
"Git 太肥" - 如果你有大型的專案Git 有能力提供淺層儲存庫,基本上這意味著它能夠減少歷史的紀錄。
### 真正的缺點
對二進位檔案來說並不適合。Git適合用在原始碼但如果是執行檔或影片這些例子就不適用
不適合用在二進位檔案。Git 適合用在原始碼,但如果是執行檔或影片就不建議
Git 對使用的人並不友善,事實上我們必須花費時間討論命令和功能。 the fact that we have to spend time talking about commands and functions of the tool is probably a key sign of that.
Git 對使用的人並不友善,事實上我們必須花費時間討論命令和功能怎麼使用
整理來說Git 困難但易用。
整理來說Git 難學好用。
### Git 生態系統
I want to briefly cover the ecosystem around git but not deep dive into some of these areas but I think its important to note these here at a high level.
我想要從宏觀的角度來介紹環繞在 Git 間的生態系統,但是我不會深入探討其中的一些領域。
Almost all modern development tools support Git.
幾乎所有的開發工具都支援 Git。
- Developer tools - We have already mentioned visual studio code but you will find git plugins and integrations into sublime text and other text editors and IDEs.
- Team tools - Also mentioned around tools like Jenkins from a CI/CD point of view, Slack from a messaging framework and Jira for project management and issue tracking.
- Cloud Providers - All the large cloud providers support git, Microsoft Azure, Amazon AWS, Google Cloud Platform.
- Git-Based services - Then we have the GitHub, GitLab and BitBucket of which we will cover in more detail later on. I have heard these services as the social network for code!
- 開發工具 - 我們曾經提到微軟的 visual studio code 有支援,其他的文字編輯器像是 sublime text 也有提供外掛整合 Git。
- 團隊工具 - 用來做持續整合/持續佈署的 Jekins Slack 的訊息框架和專案管理/問題追蹤系統 Jira。
- 雲端供應商 - 所有的雲端供應商都有支援 GitMicrosoft Azure、Amazon AWS、Google Cloud Platform。
- 基於Git的服務 - GitHub、GitLab 和 BitBucket 之後會有更詳盡的探討。我聽過這些服務是程式碼的社交網路!
### Git 備忘紙條
### Git Cheatsheet
We have not covered most of these commands but having looked at some cheatsheets available online I wanted to document some of the git commands and what their purpose are. We don't need to remember these all, and with more hands on practice and using you will pick at least the git basics.
我們沒有列出大部分可用的指令,看過一些線上的 Git cheatsheets之後我紀錄一些指令和其目的。你並不需要記下所有的指令你只要頻繁的使用自然而然就會記得。
I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet) but writing them down and reading the description is a good way to get to know what the commands are as well as getting hands on in every day tasks.
我從 [atlassian](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet) 連結抄寫上面的指令和說明,就像是每天親身參與的日常任務,這也是了解 Git 指令的一種好方法。
### Git Basics
### Git 基本操作
| Command | Example | Description |
| --------------- | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| git init | `git init <directory>` | Create an empty git repository in specified directory. |
| git clone | `git clone <repo>` | Clone repository located at<repo> onto local machine. |
| git config | `git config user.name` | Define author name to be used for all commits in current repository`system`, `global`, `local` flag to set config options. |
| git add | `git add <directory>` | Stage all changes in<directory> for the next commit. We can also add <files> and <.> for everything. |
| git commit -m | `git commit -m "<message>"` | Commit the staged snapshot, use<message> to detail what is being committed. |
| git status | `git status` | List files that are staged, unstaged and untracked. |
| git log | `git log` | Display all commit history using the default format. There are additional options with this command. |
| git diff | `git diff` | Show unstaged changes between your index and working directory. |
| 指令 | 範例 | 描述 |
| --------------- | ----------------------------- | ----------------------------------------------------------------------------------- |
| git init | `git init <directory>` | 在指定的資料夾上建立一個空的 Git 儲存庫。 |
| git clone | `git clone <repo>` | 將遠端的儲存庫複製到自己的電腦上。 |
| git config | `git config user.name` | 為目前的儲存庫定義每次提交時用的作者名,可增加配置選項`system`、`global`、`local` |
| git add | `git add <directory>` | 將檔案或目錄加入索引。也可以輸入 <.> 索引所有的檔案。 |
| git commit -m | `git commit -m "<message>"` | 將索引的檔案提交出去,-m 加入註解。 |
| git status | `git status` | 列出那些檔案已索引、未索引、未追蹤。 |
| git log | `git log` | 用預設格式列出所有提交的歷史紀錄,這個指令有其他選項可用。 |
| git diff | `git diff` | 列出你的工作目錄和索引之間有何差異。 |
### Git Undoing Changes
| Command | Example | Description |
| 指令 | 範例 | 描述 |
| ------------ | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| git revert | `git revert <commit>` | Create a new commit that undoes all of the changes made in<commit> then apply it to the current branch. |
| git revert | `git revert <commit>` | 做反向處理,回復這次提交的異動,並建立新的提供。 |
| git reset | `git reset <file>` | Remove<file> from the staging area, but leave the working directory unchanged. This unstages a file without overwriting any changes. |
| git clean | `git clean -n` | Shows which files would be removed from the working directory. Use`-f` in place of `-n` to execute the clean. |
| git clean | `git clean -n` | 列出那些檔案會從你的工作目錄刪除。`-n`改成`-f`就會真正執行刪除。 |
### Git Rewriting History
| Command | Example | Description |
| 指令 | 範例 | 描述 |
| ------------ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| 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 commits message. |
| git rebase | `git rebase <base>` | Rebase the current branch onto<base>. <base> can be a commit ID, branch name, a tag, or a relative reference to HEAD. |
@ -99,7 +99,7 @@ I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atla
### Git Branches
| Command | Example | Description |
| 指令 | 範例 | 描述 |
| -------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------- |
| git branch | `git branch` | List all of the branches in your repo. Add a<branch> argument to create a new branch with the name <branch>. |
| git checkout | `git checkout -b <branch>` | Create and check out a new branch named<branch>. Drop the -b flag to checkout an existing branch. |
@ -108,7 +108,7 @@ I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atla
### Git Remote Repositories
| Command | Example | Description |
| 指令 | 範例 | 描述 |
| ---------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| git remote add | `git remote add <name> <url>` | Create a new connection to a remote repo. After adding a remote, you can use<name> as a shortcut for <url> in other commands. |
| git fetch | `git fetch <remote> <branch>` | Fetches a specific<branch>, from the repo. Leave off <branch> to fetch all remote refs. |
@ -118,7 +118,7 @@ I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atla
### Git Diff
| Command | Example | Description |
| 指令 | 範例 | 描述 |
| ------------------- | --------------------- | ------------------------------------------------------------ |
| 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 |
@ -126,7 +126,7 @@ I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atla
### Git Config
| Command | Example | Description |
| 指令 | 範例 | 描述 |
| ----------------------------------------------------- | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| git config --global user.name<name> | `git config --global user.name <name>` | Define the author name to be used for all commits by the current user. |
| git config --global user.email<email> | `git config --global user.email <email>` | Define author email to be used for all commits by the current user. |
@ -137,21 +137,21 @@ I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atla
### Git Rebase
| Command | Example | Description |
| 指令 | 範例 | 描述 |
| --------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| git rebase -i<base> | `git rebase -i <base>` | Interactively rebase current branch onto<base>. Launches editor to enter commands for how each commit will be transferred to the new base. |
### Git Pull
| Command | Example | Description |
| 指令 | 範例 | 描述 |
| --------------------------- | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| git pull --rebase<remote> | `git pull --rebase <remote>` | Fetch the remotes copy of current branch and rebases it into the local copy. Uses git rebase instead of merge to integrate the branches. |
### Git Reset
| Command | Example | Description |
| 指令 | 範例 | 描述 |
| -------------------------- | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| 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 |
@ -161,11 +161,11 @@ I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atla
### Git Push
| Command | Example | Description |
| -------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| git push<remote> --force | `git push <remote> --force` | Forces the git push even if it results in a non-fast-forward merge. Do not use the --force flag unless youre absolutely sure you know what youre doing. |
| git push<remote> --all | `git push <remote> --all` | Push all of your local branches to the specified remote. |
| git push<remote> --tags | `git push <remote> --tags` | Tags arent automatically pushed when you push a branch or use the --all flag. The --tags flag sends all of your local tags to the remote repo. |
| 指令 | 範例 | Description |
| -------------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------- |
| git push<remote> --force | `git push <remote> --force` | 強迫推送即使會發生 non-fast-forward。不要用 --force 選項,除非你很清楚自己在做什麼。 |
| git push<remote> --all | `git push <remote> --all` | 將本地的分支推送到指令的遠端伺服器。 |
| git push<remote> --tags | `git push <remote> --tags` | push 或加上 --all 選項,預設不會傳送標籤到遠端伺服器。加上 --tags 選項才會將本地的標籤推送到遠端儲存庫。 |
## Resources
@ -177,4 +177,4 @@ I have taken these from [atlassian](https://www.atlassian.com/git/tutorials/atla
- [Complete Git and GitHub Tutorial](https://www.youtube.com/watch?v=apGV9Kg7ics)
- [Git cheatsheet](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet)
See you on [Day 38](day38.md)
See you on [第 38 天](day38.md)