Ulysses
Ulysses

Reputation: 6025

Undo all changes of one of the file among multiple committed files

I cut a branch my_branch from develop and updated 4 files.

I committed and pushed the changes several times.

Now I have to revert all changes from file2 amongst the four files and bring file2 into a state that is exactly same as it was when my_branch was cut from develop branch.

I tried

git reset HEAD file2
git checkout -- file2

But that did not work.

How may I achieve this.

Upvotes: 0

Views: 31

Answers (2)

Sajib Khan
Sajib Khan

Reputation: 24194

Checkout file2 to origin's develop branch.

$ git fetch origin
$ git checkout my_branch

$ git checkout origin/develop file2

Upvotes: 1

Marcin Pietraszek
Marcin Pietraszek

Reputation: 3214

You need to specify commit from which you'd like get file2:

git checkout HEAD^^^^ -- file2

Command above will checkut file2 from 4 commits back.

Upvotes: 1

Related Questions