iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 13
0

Day thirteen

Git tag, let’s specify a reversion number.
Git tag, 標注一個版本號碼!

Hello everyone, It’s Ray!
哈囉大家好,我是Ray!

Today I am going to share with you how to use git tag to specify a reversion number
今天我將跟大家分享git tag,如何建立一個版本號。

After we complete a series of small functions, it could mean that we are going to release a new reversion. For example, think about the online games that you’ve played.
當我們接二連三地完成了專案裡的一些功能,一系列的功能可能代表著一個版本的產生,比方來說,大家都玩過線上遊戲吧?

Every time when it released a new reversion, it came with some new function. This reversion always denotes that all those functions have been completed, also works functionally after internal testing.
每次改版時,常常都是釋出一些新的功能,這個版本號常常意味著,除了這些功能開發完成之外,並且都正常的運作著。

This reversion number is quite convenient and important to developers. For example, a series of small functions build a big function, and the completion of this big function means that a new reversion is going to be released.
這個版本號對於開發者來說非常方便與重要,這樣來解釋,一系列的小功能構成一個大功能,而這個大功能的完成也代表著新版本的推出。

Every time when we complete a small function, we commit it, and when we finish a series of small functions and make them a big one, we use git tag to specify, denoting a reversion’s release. It’s very essential and important to developers when wanting to do some testing some time after the release.
當每一次我們完成了一個小功能,我們使用git commit把它記錄下來,而當我們陸陸續續完成一系列的小功能而構成一個大功能時,我們使用git tag來標注,代表著一個版本的釋出。若日後我們需要回到這一版來做相關的一些測試的話,非常的方便!

Let’s begin with git log --oneline
輸入 git log --oneline

Above image shows what log looks like before adding a tag.
以上是我們還沒有tag之前的樣子。

Type
輸入
git tag -a v1.0 -m “The stable version of example”

As image above shown, you could see the reversion number we just added.
如上圖你可以看到我們剛剛加入的版本號 v1.0

enter
輸入

git tag

You could see the reversions that we’ve made so far.
可以看到我們至今tag的任何版本號

Now let’s create a new file, example2.html, and add some code on it.
現在讓我們新增一個檔案,example2.html,並且新增以下的code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<p>This is the experimental file created after reversion v1.0</p>
</body>
</html>

Then type
然後輸入

Git add example2.html
git commit -am “An example2 file after v1.0”
Git log --oneline

As image above shown, we are now at sixth commit, and our reversion only covers to fifth commit.
如上圖,我們目前在第六個commit,而我們的版本是在第五個commit

When we want to go back to v1.0 reversion to check, we don’t need to checkout the name of fifth commit, instead, we type the reversion name as follows:
當我們想要回到v1.0的版本時,我們不需要checkout第五個commit的名稱,我們只需要輸入版本編號即可,如下輸入:

Git checkout v1.0
Git log --oneline

As image above, we’ve gone back to v1.0.
如上圖,我們已經回到版本v1.0的紀錄了

Hope that today’s article will be helpful and useful to you. See you tomorrow.
希望我今天的文章對你有所幫助!


上一篇
如何設置Git的個人資訊?
下一篇
痾.. commit錯了怎麼辦?別緊張,我們有`git revert`
系列文
Experience of a backend novice30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言