中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何分析git對象及多層目錄

發布時間:2022-01-24 11:25:47 來源:億速云 閱讀:131 作者:柒染 欄目:開發技術

本篇文章給大家分享的是有關如何分析git對象及多層目錄,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

對于git對象的理解和實例分析

[root@localhost ~]# cd /git/[root@localhost git]# mkdir object[root@localhost object]# vim main.c

Hello wnayan!

[root@localhost object]# git hash-object main.c   //計算main.c的哈希值

d32fe487dc38cbfc7fe051a5d6dbae01551d8dbd

[root@localhost object]# git init

Initialized empty Git repository in /git/object/.git/

[root@localhost object]# git add .

以下這個文件(blob)就是保存mia.c內容的文件

[root@localhost object]# ll .git/objects/d3/

total 8

-r–r–r– 1 root root 30 Nov 27 04:02 2fe487dc38cbfc7fe051a5d6dbae01551d8dbd

[root@localhost object]# git commit -m “1st commint”[master (root-commit) da97249] 1st commint

files changed, 1 insertions(+), 0 deletions(-)

create mode 100644 main.c

[root@localhost object]# find .git/objects/ -type f  //列出文件夾下的普通文件

.git/objects/ae/eedc3b20507db9600f7f72431557fcf9303252

.git/objects/d3/2fe487dc38cbfc7fe051a5d6dbae01551d8dbd

.git/objects/da/97249d3649b1770b5cec8fa515833ea596f26f

[root@localhost object]# git show d32f  //查看blob的內容,就是main.c的一樣的內容

Hello wnayan!

[root@localhost object]# git cat-file -t aeeedc   //這三句是查看object的類型

tree

[root@localhost object]# git cat-file -t da97

commit

[root@localhost object]# git cat-file -t d32f

blob

以上三種對象中tree保存文件的名字,blob保存文件的內容,這種結構有利于兩個內容相同但是名字不同的文件的保存(tree保存兩個名字,blob保存一份內容就可以了)

[root@localhost object]# git ls-tree aeee   //列出tree和blob的對應關系

100644 blob d32fe487dc38cbfc7fe051a5d6dbae01551d8dbd      main.c

[root@localhost object]# git show -s –pretty=raw da97  //查看commit的內容,關系很明確

commit da97249d3649b1770b5cec8fa515833ea596f26f

tree aeeedc3b20507db9600f7f72431557fcf9303252

author ethnicitybeta1322337880 +0800

committer ethnicitybeta1322337880 +0800

1st commint

多層目錄的實例

[root@localhost /]# mkdir -p /git/wanyan[root@localhost /]# cd /git/wanyan/[root@localhost wanyan]# cat README

just test!

[root@localhost wanyan]# cat lib/comment

include

[root@localhost wanyan]# cat lib/include/main.c

main

[root@localhost wanyan]# git init

Initialized empty Git repository in /git/wanyan/.git/

[root@localhost wanyan]# git add .[root@localhost wanyan]# git commit -m “1st version”[master (root-commit) 206ecf2] 1st version

3 files changed, 3 insertions(+), 0 deletions(-)

create mode 100644 README

create mode 100644 lib/comment

create mode 100644 lib/include/main.c

[root@localhost wanyan]# find .git/objects/ -type f  //查看生成的對象

.git/objects/03/e86fb4437c4153cec24aa4021dca582abc0558

.git/objects/56/2f7710be64f9309a9fe6aa529753953dbe7e47

.git/objects/20/6ecf269d0f540995d88d6be825fecb09b5d3eb

.git/objects/8f/006adb88a619f20442a9eb3148cff31691eaf0

.git/objects/ba/2906d0666cf726c7eaadd2cd3db615dedfdf3a

.git/objects/90/48a2fd8c21a70a2dffcf80c819eee2fb491a31

.git/objects/a1/a869c8c840478164594a788ae5ce38dc0ee6da

[root@localhost wanyan]# git cat-file -t 03e8  //可以通過這個命令依次查看對象的類型

tree

[root@localhost wanyan]# ll .git/HEAD

-rw-r–r– 1 root root 23 Nov 27 04:23 .git/HEAD  //當前使用的commit是master

[root@localhost wanyan]# cat .git/HEAD

ref: refs/heads/master

[root@localhost wanyan]# cat .git/refs/heads/master

206ecf269d0f540995d88d6be825fecb09b5d3eb

[root@localhost wanyan]# git cat-file -t 206e

commit

接下來就是修改任意的文件,來生成第多個版本的測試

[root@localhost wanyan]# cd lib/[root@localhost lib]# cat comment

include

change

[root@localhost wanyan]# git commit -a -m “2nd commit”  //這個命令是那兩個命令的綜合[master a7772df] 2nd commit

1 files changed, 1 insertions(+), 0 deletions(-)

[root@localhost wanyan]# find .git/objects/ -type f   //可以發現對象明顯的增加

.git/objects/5f/eaaa33f5f3b3bc5fae0b750b2a5ebdc74b0a27

.git/objects/03/e86fb4437c4153cec24aa4021dca582abc0558

.git/objects/56/2f7710be64f9309a9fe6aa529753953dbe7e47

.git/objects/57/440fcc9bc816076d418a2da304a2498b928bae

.git/objects/20/6ecf269d0f540995d88d6be825fecb09b5d3eb

.git/objects/8f/006adb88a619f20442a9eb3148cff31691eaf0

.git/objects/ba/2906d0666cf726c7eaadd2cd3db615dedfdf3a

.git/objects/90/48a2fd8c21a70a2dffcf80c819eee2fb491a31

.git/objects/a1/a869c8c840478164594a788ae5ce38dc0ee6da

.git/objects/a7/772df6deb98005cf5ee21ae3ea863296677923

.git/objects/2c/f3d62adf771c30fa8062ce2c491d14486ea5ee

接下來這個步驟就是來打tag,tag分為輕量級的和全面包含的

首先是輕量級的tag這個tag雖然是對象,但是并不在對象目錄里顯示(object目錄)

[root@localhost wanyan]# git tag v1.0[root@localhost wanyan]# ll .git/refs/tags/

total 8

-rw-r–r– 1 root root 41 Nov 27 04:50 v1.0

[root@localhost wanyan]# cat .git/refs/tags/v1.0   //可以發現內容是commit呀

a7772df6deb98005cf5ee21ae3ea863296677923

[root@localhost wanyan]# git cat-file -t a777

commit

然后是全面包含的tag,目錄里顯示(object目錄)

[root@localhost wanyan]# git tag -a stable1.0 -m “1st stable”[root@localhost wanyan]# find .git/objects/ -type f

.git/objects/5f/eaaa33f5f3b3bc5fae0b750b2a5ebdc74b0a27

.git/objects/03/e86fb4437c4153cec24aa4021dca582abc0558

.git/objects/56/2f7710be64f9309a9fe6aa529753953dbe7e47

.git/objects/57/440fcc9bc816076d418a2da304a2498b928bae

.git/objects/20/6ecf269d0f540995d88d6be825fecb09b5d3eb

.git/objects/8f/006adb88a619f20442a9eb3148cff31691eaf0

.git/objects/ba/2906d0666cf726c7eaadd2cd3db615dedfdf3a

.git/objects/90/48a2fd8c21a70a2dffcf80c819eee2fb491a31

.git/objects/a1/a869c8c840478164594a788ae5ce38dc0ee6da

.git/objects/a7/772df6deb98005cf5ee21ae3ea863296677923

.git/objects/8a/26be084ddce5e8178ca91def21e0c8f7a0945e

.git/objects/2c/f3d62adf771c30fa8062ce2c491d14486ea5ee

[root@localhost wanyan]# git cat-file -t 8a26

Tag

接下來演示tag的使用

[root@localhost wanyan]# vi README   //修改一下

just test!

another hang!

[root@localhost wanyan]# git commit -a -m “3rd commit”[master a08fc01] 3rd commit

1 files changed, 1 insertions(+), 0 deletions(-)

[root@localhost wanyan]# cat README

just test!

another hang!

下邊的操作演示的是把tag那個狀態(修改之前),那個打包出去

[root@localhost wanyan]# git archive –format=tar –prefix=wanyan/ v1.0 | gzip > /tmp/wanyan.tar.gz[root@localhost wanyan]# cd /tmp/[root@localhost tmp]# tar zxvf wanyan.tar.gz

wanyan/

wanyan/README

wanyan/lib/

wanyan/lib/comment

wanyan/lib/include/

wanyan/lib/include/main.c

[root@localhost tmp]# cd wanyan[root@localhost wanyan]# cat README   //是不是發現又是tag那個狀態的文件

just test!

以上就是如何分析git對象及多層目錄,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

git
AI

荔浦县| 桂林市| 锡林浩特市| 互助| 巴彦淖尔市| 昔阳县| 泸州市| 嵊州市| 渭南市| 大同市| 普格县| 石阡县| 施秉县| 眉山市| 巨鹿县| 依兰县| 开化县| 阳谷县| 海宁市| 襄汾县| 尼勒克县| 林芝县| 皋兰县| 平遥县| 乌鲁木齐县| 托克逊县| 太白县| 寿光市| 隆子县| 太康县| 固安县| 阳春市| 唐山市| 顺昌县| 乐都县| 鸡西市| 楚雄市| 藁城市| 克东县| 黄浦区| 横峰县|