HEAD 指標操作

2021-10-24 02:01:36 字數 4664 閱讀 3340

多對資料倉儲進行修改、提交操作,以產生多個版本

[root@client project]

# echo "new file" > new.txt

[root@client project]

# git add .

[root@client project]

# git commit -m "add new.txt"

[root@client project]

# echo "first" >> new.txt

[root@client project]

# git add .

[root@client project]

# git commit -m "new.txt:first line"

[root@client project]

# echo "second" >> new.txt

[root@client project]

# git add .

[root@client project]

# git commit -m "new.txt:second"

[root@client project]

# echo "third" >> new.txt

[root@client project]

# git add .

[root@client project]

# git commit -m "new.txt:third"

[root@client project]

# git push

[root@client project]

# echo "123" > num.txt

[root@client project]

# git add .

[root@client project]

# git commit -m "num.txt:123"

[root@client project]

# echo "456" > num.txt

[root@client project]

# git add .

[root@client project]

# git commit -m "num.txt:456"

[root@client project]

# echo "789" > num.txt

[root@client project]

# git add .

[root@client project]

# git commit -m "num.txt:789"

[root@client project]

# git push

[root@client project]

# git log --pretty=oneline

bc342702c0ec2cc8ea070b859657c1162079404e num.txt:789

5cd5009d4de93630d68fc6f0fd471ad9dec2d571 num.txt:456

9facc5f5d36eb5259c67e046b0bae276452d4ef3 num.txt:123

38186bcc0c492d73329b74b777ec920bc1d0a981 new.txt:third

bf54a2e0e8f1de8742490a650aae4ff177390c3a new.txt:second

18c9e29d142c4d87034cba203eb234b845a04e8f new.txt:first line

ba078651a4d62f5476eb39f78f7fd966e6a2073c add.new.txt

5ffa75da29cceec8582006c91790f9994169ccd9 注釋,可以為任意字元

ff470ad0020a9ead67c8ac416369d2a1c8906d69 注釋,可以為任意字元

[root@client project]

# git reflog

bc34270 head@: commit: num.txt:789

5cd5009 head@: commit: num.txt:456

9facc5f head@: commit: num.txt:123

38186bc head@: commit: new.txt:third

bf54a2e head@: commit: new.txt:second

18c9e29 head@: commit: new.txt:first line

ba07865 head@: commit: add.new.txt

5ffa75d head@: pull: fast-forward

ff470ad head@: commit (initial): 注釋,可以為任意字元

[root@client project]

# git reset --hard 9facc5f

head 現在位於 9facc5f num.txt:123

[root@client project]

# git reflog #檢視指標移動歷史

9facc5f head@: reset: moving to 9facc5f

bc34270 head@: commit: num.txt:789

5cd5009 head@: commit: num.txt:456

9facc5f head@: commit: num.txt:123

38186bc head@: commit: new.txt:third

bf54a2e head@: commit: new.txt:second

18c9e29 head@: commit: new.txt:first line

ba07865 head@: commit: add.new.txt

5ffa75d head@: pull: fast-forward

ff470ad head@: commit (initial): 注釋,可以為任意字元

[root@client project]

# cat num.txt #檢視檔案是否為123

123[root@client project]

# git reset --hard 5cd5009

head 現在位於 5cd5009 num.txt:456

[root@client project]

# git reflog #檢視指標移動歷史

5cd5009 head@: reset: moving to 5cd5009

9facc5f head@: reset: moving to 9facc5f

bc34270 head@: commit: num.txt:789

5cd5009 head@: commit: num.txt:456

9facc5f head@: commit: num.txt:123

38186bc head@: commit: new.txt:third

bf54a2e head@: commit: new.txt:second

18c9e29 head@: commit: new.txt:first line

ba07865 head@: commit: add.new.txt

5ffa75d head@: pull: fast-forward

ff470ad head@: commit (initial): 注釋,可以為任意字元

[root@client project]

# cat num.txt #檢視檔案是否為456

456[root@client project]

# git reset --hard bc34270 #回到最後一次修改的版本

head 現在位於 bc34270 num.txt:789

[root@client project]

# git reflog #檢視指標移動歷史

bc34270 head@: reset: moving to bc34270

5cd5009 head@: reset: moving to 5cd5009

9facc5f head@: reset: moving to 9facc5f

bc34270 head@: commit: num.txt:789

5cd5009 head@: commit: num.txt:456

9facc5f head@: commit: num.txt:123

38186bc head@: commit: new.txt:third

bf54a2e head@: commit: new.txt:second

18c9e29 head@: commit: new.txt:first line

ba07865 head@: commit: add.new.txt

5ffa75d head@: pull: fast-forward

ff470ad head@: commit (initial): 注釋,可以為任意字元

[root@client project]

# cat num.txt #檢視檔案是否為789

789

HEAD指標操作

2.1 問題 沿用練習一,學習操作head指標,具體要求如下 檢視git版本資訊 移動指標 通過移動head指標恢復資料2.2 方案 head指標是乙個可以在任何分支和版本移動的指標,通過移動指標我們可以將資料還原至任何版本。每做一次提交操作都會導致git更新乙個版本,head指標也跟著自動移動。2...

Linux 操作命令 head

1 簡介 head 命令顯示 文件的開頭至標準輸出中 2 主要功能 顯示 文件的開頭至標準輸出中,預設 head 命令列印 檔案的 頭 10 行 3 用法 命令格式 head 選項 檔案 4 常用引數解析 語法 引數 說明 head 顯示 文件的開頭至標準輸出中 預設顯示10行 5 輔助功能 5.1...

ES基本查詢及HEAD操作

一 基本查詢操作 選擇索引 設定type查詢條件 搜尋操作說明如圖 二 must,must not,should的區別 must 返回的文件必須滿足must子句的條件,類似於 and must not返回的文件必須不滿足must not 子句的條件 類似於 not should 返回的文件只要滿足s...