0

I have two commits merged into a single commit with specific change id

commit fea9c375f216a75c6a2a2fcc9c903a5992d3679e
    adding Field
    Change-Id: Id07dd67b412d56f64e05246ea0b87924f8a803cb

Now i have 5 files commited in this..

I have to revert only one file in this commit. Is it possible?

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

I tried git reset fea9c37 <filename>

but the changes are still present in the file.

How do i revert this?

Barett
  • 5,826
  • 6
  • 51
  • 55
Aishu
  • 27
  • 2
  • 6

1 Answers1

2

You can use git checkout to revert a file to a previous commit.

e.g.: git checkout Id07dd67b412d56f64e05246ea0b87924f8a803cb path/to/file

(where Id07d... is the commit you want to reset the file to -- before the change)

Daniel May
  • 8,156
  • 1
  • 33
  • 43