From 710eb45086717a0eacb1e285eb75b297619d5135 Mon Sep 17 00:00:00 2001 From: Awin Huang Date: Thu, 17 Nov 2022 14:25:37 +0800 Subject: [PATCH] vault backup: 2022-11-17 14:25:37 --- .obsidian/workspace.json | 30 +++++++++++----- 05. 資料收集/軟體工具/git/tag.md | 61 ++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 05. 資料收集/軟體工具/git/tag.md diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index e773d50..36bdb77 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -37,14 +37,26 @@ "state": { "type": "markdown", "state": { - "file": "00. Inbox/01. TODO.md", + "file": "05. 資料收集/軟體工具/git/apply.md", + "mode": "source", + "source": true + } + } + }, + { + "id": "7c7ea3aad0c7e405", + "type": "leaf", + "state": { + "type": "markdown", + "state": { + "file": "05. 資料收集/軟體工具/git/tag.md", "mode": "source", "source": true } } } ], - "currentTab": 2 + "currentTab": 3 } ], "direction": "vertical" @@ -102,7 +114,7 @@ "state": { "type": "backlink", "state": { - "file": "00. Inbox/01. TODO.md", + "file": "05. 資料收集/軟體工具/git/tag.md", "collapseAll": false, "extraContext": false, "sortOrder": "alphabetical", @@ -119,7 +131,7 @@ "state": { "type": "outline", "state": { - "file": "00. Inbox/01. TODO.md" + "file": "05. 資料收集/軟體工具/git/tag.md" } } } @@ -147,17 +159,17 @@ "direction": "horizontal", "width": 319.5 }, - "active": "3fa89edb394e69a4", + "active": "7c7ea3aad0c7e405", "lastOpenFiles": [ - "02. 工作/01. Logitech/Sentinel.md", + "05. 資料收集/軟體工具/git/apply.md", + "05. 資料收集/軟體工具/git/submodule.md", "00. Inbox/01. TODO.md", + "02. 工作/01. Logitech/Sentinel.md", "02. 工作/01. Logitech/Tiny.md", "04. Programming/FFMPEG/FFMpeg.md", "04. Programming/FFMPEG/00. Introduction.md", "02. 工作/01. Logitech/Kong.md", "01. 個人/01. Daily/2022-10-22(週六).md", - "01. 個人/01. Daily/2022-10-18(週二).md", - "01. 個人/01. Daily/2022-10-17(週一).md", - "05. 資料收集/99. templates/日記.md" + "01. 個人/01. Daily/2022-10-18(週二).md" ] } \ No newline at end of file diff --git a/05. 資料收集/軟體工具/git/tag.md b/05. 資料收集/軟體工具/git/tag.md new file mode 100644 index 0000000..e15c924 --- /dev/null +++ b/05. 資料收集/軟體工具/git/tag.md @@ -0,0 +1,61 @@ +## 列出你的標籤 +``` +$ git tag +v0.1 +v1.3 +``` + +## 建立新的標籤 +```console +$ git tag -a v1.4 -m "my version 1.4" +$ git tag +v0.1 +v1.3 +v1.4 +``` + +## 輕量級標籤 +如果想要建立一個輕量級的標籤,不要指定 `-a`、`-s` 或 `-m` 的選項如下: +```console +$ git tag v1.4-lw +$ git tag +v0.1 +v1.3 +v1.4 +v1.4-lw +v1.5 +``` + +## 分享標籤 +`git push` 指令預設不會傳送標籤到遠端伺服器。 在你建立標籤後,你必須明確的要求 Git 將標籤推送到共用的伺服器上面。 這個動作就像是在分享遠端分支一樣——你可以執行 `git push origin [tagname]`。 +```console +$ git push origin v1.5 +Counting objects: 14, done. +Delta compression using up to 8 threads. +Compressing objects: 100% (12/12), done. +Writing objects: 100% (14/14), 2.05 KiB | 0 bytes/s, done. +Total 14 (delta 3), reused 0 (delta 0) +To git@github.com:schacon/simplegit.git + * [new tag] v1.5 -> v1.5 +``` + +如果想要一次推送很多標籤,也可以在使用 `git push` 指令的時候加上 `--tags` 選項。 這將會把你所有不在伺服器上面的標籤傳送給遠端伺服器。 +```console +$ git push origin --tags +Counting objects: 1, done. +Writing objects: 100% (1/1), 160 bytes | 0 bytes/s, done. +Total 1 (delta 0), reused 0 (delta 0) +To git@github.com:schacon/simplegit.git + * [new tag] v1.4 -> v1.4 + * [new tag] v1.4-lw -> v1.4-lw +``` + +## 檢出標籤 +在 Git 中你不能真的檢出一個標籤,因為它們並不能像分支一樣四處移動。 如果你希望工作目錄和版本庫中特定的標籤版本完全一樣,你可以使用 `git checkout -b [branchname] [tagname]` 在該標籤上建立一個新分支: + +```console +$ git checkout -b version2 v2.0.0 +Switched to a new branch 'version2' +``` + +當然,如果在建立新分支以後又進行了一次提交,`version2` 分支將會和 `v2.0.0` 標籤有所差異,因為這個分支已經因為你的提交而改變了,請特別小心。