我對git非常陌生,我正在探索git。即使狀態很乾淨,Git還原失敗
這是我輸入的命令鏈。
C:\Users\User\Documents\GitHub> cd test
C:\Users\User\Documents\GitHub\test> git init
Initialized empty Git repository in C:/Users/User/Documents/GitHub/test/.git/
C:\Users\User\Documents\GitHub\test [master]> touch 2.txt
C:\Users\User\Documents\GitHub\test [master +1 ~0 -0 !]> git add .
C:\Users\User\Documents\GitHub\test [master +1 ~0 -0]> git commit -a
[master (root-commit) 1af7554] init commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 2.txt
C:\Users\User\Documents\GitHub\test [master]> notepad .\2.txt
C:\Users\User\Documents\GitHub\test [master]> git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: 2.txt
no changes added to commit (use "git add" and/or "git commit -a")
C:\Users\User\Documents\GitHub\test [master +0 ~1 -0]> git add .
C:\Users\User\Documents\GitHub\test [master +0 ~1 -0]> git commit -m "changed file 2"
[master 494394c] changed file 2
1 file changed, 1 insertion(+)
C:\Users\User\Documents\GitHub\test [master]> git log
commit 494394c1c4b5131526ad5137febba54442211303
Author: email
Date: Tue Jun 14 14:15:37 2016 +0800
changed file 2
commit 1af755406aad60fb014c496548ea198d59a1af52
Author: email
Date: Tue Jun 14 14:15:10 2016 +0800
init commit
C:\Users\User\Documents\GitHub\test [master]> git revert 1af755
error: could not revert 1af7554... init commit
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
C:\Users\User\Documents\GitHub\test [master +0 ~0 -0 !1 | +0 ~0 -1]> 3b0c5670
我還是不明白,爲什麼我得到一個混帳復歸錯誤
494394是依賴於1af755的提交。您不能僅恢復1af755。當您恢復1af755時,2.txt將被刪除。但是494394需要該文件存在。所以有衝突。您必須決定是保留還是刪除文件。 – ElpieKay