Git使用筆記

2021-08-07 21:10:18 字數 990 閱讀 1837

記錄使用git遇到的問題及解決方法

commit出錯,需要撤銷指定的commit。從看到解決辦法。但是此方法存在***,撤銷某次commit後,其之後的commit也全被撤銷。

執行git log檢視日誌。

$ git log

commit 2f87e75a91004bc233b568b234cd5978df5c2cb9

author: onetarolv <>

date: thu sep 7

14:14:18

2017 +0800

download link of data files

commit 672876df5ab5940ae6cfc89a5abb78fbcc55bdff

author: onetarolv <>

date: tue aug 29

16:00:37

2017 +0800

docword

commit f936707da84194f7ee829d5cd5a8de7b2c681820

author: onetarolv <>

date: mon aug 21

14:0

add changed files

如果要撤銷message為「docword」的commit,則需要檢視其上一條的commit 的id,即 「add changed files」的id。執行 git reset –hard id。如下

$ git reset --hard f936707da84194f7e829d5cd5a8de7b2c681820

head is now at f936707 add changed files

執行後,commit的狀態恢復到「add changed files」commit之後的狀態,「docowrd」這次commit及其之後的commit都被撤銷了。

git 使用筆記

git 使用筆記 初始化資訊 git config user.name name git config user.email com git config core.editor vim git init 初始化資訊 從遠端pull git clone git url git pull push 到...

git使用筆記

回滾 git checkout sql 沒有 git add 之前 執行回滾到原始狀態 git reset head sql 執行git add之後,但是沒有 git commit之前 操作,然後在執行 git checkout git remote v 檢視遠端倉庫詳細資訊 git log log...

Git使用筆記

用了一段時間的tortoisgit,基本能滿足目前的需求。但是當切換到linux的工作環境時,就有點不知所措了,於是又複習了一下git的命令,相對於第一次學習,又有了新的認識。工作區 working tree 所有有改動的檔案都存在於工作區。暫存區 index 對於已經存在於工作區的檔案,執行git...