@ -209,7 +209,7 @@ A Pod is a group of containers that form a logical application. For e.g. If you
- a unified way to route traffic to a cluster and eventually to a list of Pods.
- By using a Service, Pods can be brought up and down without affecting anything..
- By using a Service, Pods can be brought up and down without affecting anything.
This is just a quick overview and notes around the fundamental building blocks of Kubernetes, we can take this knowledge and add in some other areas around Storage and Ingress to enhance our applications but we then also have a lot of choices on where our Kubernetes cluster runs. The next session will focus on those options on where can I run a Kubernetes cluster, whilst also exploring some specifics around Storage.
description: 90DaysOfDevOps - The Big Picture Git - Version Control
tags: 'devops, 90daysofdevops, learning'
description: 90DaysOfDevOps - 概述 Git - 版本控制
tags: 'devops,90daysofdevops,learning'
cover_image: null
canonical_url: null
id: 1049041
---
## The Big Picture: Git - Version Control
## 概述: Git - 版本控制
Before we get into git, we need to understand what version control is and why? In this opener for Git, we will take a look at what version control is, the basics of git.
Git is not the only version control system so here we want to cover what options and what methodologies are available around version control.
由於 Git 並不是唯一的版本控制工具,所以這一節將會涵蓋版本控制有哪些選項和使用方法。
The most obvious and a big benefit of Version Control is the ability to track a project's history. We can look back over this repository using `git log` and see that we have many commits and many comments and what has happened so far in the project. Don't worry we will get into the commands later. Now think if this was an actual software project full of source code and multiple people are committing to our software at different times, different authors and then reviewers all are logged here so that we know what has happened, when, by whom and who reviewed.
Version Control before it was cool, would have been something like manually creating a copy of your version before you made changes. It might be that you also comment out old useless code with the just in case mentality.
I have started using version control over not just source code but pretty much anything, talks about projects like this (90DaysOfDevOps) because why would you not want that rollback and log of everything that has gone on.
However, a big disclaimer **Version Control is not a Backup!**
然而,在此聲明 **版本控制不是備份!**
Another benefit of Version Control is the ability to manage multiple versions of a project, Let's create an example, we have a free app that is available on all operating systems and then we have a paid-for app also available on all operating systems. The majority of the code is shared between both applications. We could copy and paste our code each commit to each app but that is going to be very messy especially as you scale your development to more than just one person, also mistakes will be made.
The premium app is where we are going to have additional features, let's call them premium commits, the free edition will just contain the normal commits.
白金方案(Premium)的軟體擁有額外的功能,在這裡我們稱為 premium commits,免費版只包含 normal commits。
The way this is achieved in Version Control is through branching.
在版本控制中,想要處理上述的問題需要透過分支(Branching)。

Branching allows for two code streams for the same app as we stated above. But we will still want new features that land in our source code free version to be in our premium and to achieve this we have something called merging.
Now, this same easy but merging can be complicated because you could have a team working on the free edition and you could have another team working on the premium paid for version and what if both change code that affects aspects of the overall code. Maybe a variable gets updated and breaks something. Then you have a conflict that breaks one of the features. Version Control cannot fix the conflicts that are down to you. But version control allows this to be easily managed.
The primary reason if you have not picked up so far for version control, in general, is the ability to collaborate. The ability to share code amongst developers and when I say code as I said before more and more we are seeing much more use cases for other reasons to use source control, maybe its a joint presentation you are working on with a colleague or a 90DaysOfDevOps challenge where you have the community offering their corrections and updates throughout the project.
Without version control how did teams of software developers even handle this? I find it hard enough when I am working on my projects to keep track of things. I expect they would split out the code into each functional module. Maybe a little part of the puzzle then was bringing the pieces together and then problems and issues before anything would get released.
Another thing to mention here is that it's not just developers that can benefit from Version Control, it's all members of the team to have visibility but also tools all having awareness or leverage, Project Management tools can be linked here, tracking the work. We might also have a build machine for example Jenkins which we will talk about in another module. A tool that Builds and Packages the system, automating the deployment tests and metrics.
There are many ways in which git can be used on our systems, most commonly or at least for me I have seen it in at the command line, but we also have graphical user interfaces and tools like Visual Studio Code that have git aware operations we can take advantage of.
我們的系統有很多種 Git 使用方法,對我來說最常看到的用法是輸入指令,但它也有圖形使用者介面,如微軟開發的 Visual Studio Code 只要透過界面按鈕就可輕鬆管理。
Now we are going to run through a high-level overview before we even get Git installed on our local machine.
在教學如何安裝 Git 之前,我們先瀏覽了一下 Git 怎麼使用。
Let's take the folder we created earlier.
我們先用之前建立的資料夾來當範例。

To use this folder with version control we first need to initiate this directory using the `git init command. For now, just think that this command puts our directory as a repository in a database somewhere on our computer.
Now we can create some files and folders and our source code can begin or maybe it already has and we have something in here already. We can use the `git add .` command which puts all files and folders in our directory into a snapshot but we have not yet committed anything to that database. We are just saying all files with the `.` are ready to be added.
Then we want to go ahead and commit our files, we do this with the `git commit -m "My First Commit"` command. We can give a reason for our commit and this is suggested so we know what has happened for each commit.
然後我們想要進一步提交檔案,這個時候就可以輸入 `git commit -m "My First Commit"`。建議提交時寫一些註解,這將幫助我們了解發生了什麼事。


We can now see what has happened within the history of the project. Using the `git log` command.
現在我們可以透過 `git log` 指令,回顧專案的歷史和註解。

We can also check the status of our repository by using `git status` this shows we have nothing to commit and we can add a new file called samplecode.ps1. If we then run the same `git status you will see that we file to be committed.
Which then displays what has changed in our case we added a new file.
於是以我們的案例來看,很清楚的顯示我們添加了一個文件。

We can also and we will go deeper into this later on but we can jump around our commits i.e we can go time travelling! By using our commit number we can use the `git checkout 709a` command to jump back in time without losing our new file.
But then equally we will want to move forward as well and we can do this the same way with the commit number or you can see here we are using the `git switch -` command to undo our operation.
- Sharing code amongst developers and a wider scope of teams and tools
- Coordinating teamwork
- Oh and there is some time travel!
- 追蹤專案的歷史
- 管理一個專案內不同版本的程式碼
- 在開發人員在開發人員和更廣泛的團隊和工具之間共享程式碼
- 協調團隊合作
- 哦,還有一些做時間旅行!
This might have seemed a jump around but hopefully, you can see without really knowing the commands used the powers and the big picture behind Version Control.
Next up we will be getting git installed and set up on your local machine and diving a little deeper into some other use cases and commands that we can achieve in Git.
Later on you are going to see how this looks when deployed into Kubernetes, in particular we have the **PushGateway** which pulls our metrics from our jobs/exporters.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.