关于github:git commit之后,是否可以只还原一个文件?

After git commit, Is it possible to revert only one file?

我将两个提交合并为一个具有特定更改ID的提交

1
2
3
commit fea9c375f216a75c6a2a2fcc9c903a5992d3679e
    adding Field
    Change-Id: Id07dd67b412d56f64e05246ea0b87924f8a803cb

现在我已经提交了5个文件……

在这个提交中,我只需要恢复一个文件。有可能吗?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
git reflog
fea9c37 HEAD@{0}: reset: moving to ORIG_HEAD

6bf010f HEAD@{1}: rebase -i (finish): returning to refs/heads/dev

6bf010f HEAD@{2}: rebase -i (pick): adding Field

2a0b1d7 HEAD@{3}: rebase -i (start): checkout remotes/gerrit/dev

fea9c37 HEAD@{4}: rebase -i (finish): returning to refs/heads/dev

fea9c37 HEAD@{5}: rebase -i (squash): adding Field

e2f9b47 HEAD@{6}: rebase -i (start): checkout refs/remotes/origin/dev

27cc4f3 HEAD@{7}: checkout: moving from bf4a4564ed3ddcb1de1114f2d020d65ead2e9999 to dev

bf4a456 HEAD@{8}: rebase -i (start): checkout refs/remotes/origin/dev

27cc4f3 HEAD@{9}: commit: printField

e2f9b47 HEAD@{10}: commit (amend): adding Field

afddac7 HEAD@{11}: reset: moving to ORIG_HEAD

a614916 HEAD@{12}: rebase -i (finish): returning to refs/heads/dev

a614916 HEAD@{13}: rebase -i (pick): adding Field

c766b57 HEAD@{14}: rebase -i (start): checkout remotes/gerrit/dev

afddac7 HEAD@{15}: commit: adding Field

bf4a456 HEAD@{16}: pull: Fast-forward

5d63ab1 HEAD@{17}: checkout: moving from master to dev

我试过了git reset fea9c37

但是这些更改仍然存在于文件中。

我该如何恢复?


您可以使用git checkout将文件恢复到以前的提交。

例如。:江户十一〔一〕号

(其中,Id07d...是要将文件重置为的提交—在更改之前)